Difference between revisions of "Linux command line basics"

From eLinux.org
Jump to: navigation, search
(Fixed up a few errors)
Line 1: Line 1:
 
[[Category:UDOO]]
 
[[Category:UDOO]]
Linux Command Line Interface, (CLI from now on) could be at first glance discouraging for the average Joe, since nowadays we are only used to Graphic Interfaces. But don’t let you down, using a command line shell could be, not only very useful, but also kind of funny. This guide will help you move your first steps in the command shell environment.
+
Linux Command Line Interface (CLI from now on) could be at first glance discouraging for the average Joe, since nowadays we are only used to Graphic Interfaces. But don’t get let down, using a command line shell could be not only very useful, but also kind of funny. This guide will help you make your first steps in the command shell environment.
  
First, when a Command Line Interface could be useful for you?  
+
First, when could a Command Line Interface be useful for you?
  
*Remote Connection via SSH: SSH remote connection allows to interact with UDOO without physical access to it. SSH is available only with command line interface.  
+
*Remote Connection via SSH: SSH remote connection allows you to interact with UDOO without physical access to it. SSH is available only with command line interface.  
  
*Using a minimal Linux Distribution without a graphical interface. Some Linux Distribution come without a Graphical User Interface, in order to maximize available resources. Command line interface is your only bet in this scenario Some power-users consider CLI the most convenient way to perform code execution and file-system operations. Even if you are not in this category, you may found out that CLI can be very fast when you get used to it.  
+
*Using a minimal Linux Distribution without a graphical interface. Some Linux Distributions come without a Graphical User Interface in order to maximize available resources. Command line interface is your only bet in this scenario. Some power-users consider CLI the most convenient way to perform code execution and file-system operations. Even if you are not in this category, you may find that the CLI can be very fast when you get used to it.  
  
 
To help you get started, here are some very basic Linux commands:
 
To help you get started, here are some very basic Linux commands:
Line 12: Line 12:
 
  sudo
 
  sudo
  
Your first ally, allows users to run programs with the security privileges of root, or superuser.Its name is a concatenation of “su” (substitute user) and “do”, or take action . So, if you get an error message saying that “only root can do that”, just use the same command with preceeded by sudo.
+
Your first ally, this command allows users to run programs with the security privileges of root, or superuser. Its name is a concatenation of “su” (super user) and “do”, or take action . So, if you get an error message saying “only root can do that”, just use the same command preceded with sudo.
  
 
  sudo su
 
  sudo su
  
This just enables root privileges once for all, without forcing you to type sudo everytime. It works until you close the shell you are working into.  
+
This enables root privileges once for all, without forcing you to type sudo everytime. It works until you close the shell you are working in.  
  
 
  sudo su touch
 
  sudo su touch
  
create an empty file   
+
Creates an empty file   
  
 
  nano
 
  nano
  
open an handy text editor, to save and exit, press “ctrl” and “x”, and tell yes or no by pressing “y” or “n”
+
Open an handy text editor. To save and exit, press “ctrl” and “x”, and press “y” for yes or “n” for no.
  
 
  cat
 
  cat
  
cat shows the content of a file, it speeds up file inspection for smaller files. eg: cat /etc/hostname  
+
Shows the content of a file, it speeds up file inspection for smaller files. e.g. cat /etc/hostname  
  
 
  ls
 
  ls
  
Shows you the content of a folder  
+
Lists the contents of the current folder.
  
 
  cd
 
  cd
opens a specific folder  
+
 
 +
Changes current folder to specific folder.
  
 
  cd..
 
  cd..
  
Brings you to a higher folder level  
+
Changes current folder to a higher folder level.
  
 
  cd /
 
  cd /
  
brings you to root (top filesystem level)  
+
Changes current folder to root (top filesystem level)  
  
 
  rm
 
  rm
deletes a file  
+
 
 +
Deletes a file.
  
 
  rm -rf
 
  rm -rf
  
deletes a folder  
+
Deletes a folder.
  
 
  mv
 
  mv
  
moves a file or a folder. Useful for renaming also eg mv myfile /myfolder/myfile mv myfile mysecondfile  
+
Moves a file or a folder. Useful for renaming also, e.g. mv myfile /myfolder/myfile and mv myfile mysecondfile
  
 
  cp
 
  cp
  
copies a file e.g. cp myfile /home/ubuntu/  
+
Copies a file, e.g. cp myfile /home/ubuntu/  
  
 
  cp -R
 
  cp -R
  
copies a folder e.g. cp -R myfolder /home/ubuntu/myfolder  
+
Copies a folder, e.g. cp -R myfolder /home/ubuntu/myfolder
  
 
  mkdir
 
  mkdir
  
creates a folder  
+
Creates a folder  
  
 
  top
 
  top
  
Top is a very useful utility, it basically gives you a complete overview of the system’s status. It produces an ordered list of running processes selected by user-specified criteria. Top shows how much processing power and memory are being used, as well as other information about the running processes.  
+
Top is a very useful utility, it basically gives you a complete overview of the system's status. It produces an ordered list of running processes selected by user-specified criteria. Top shows how much processing power and memory are being used, as well as other information about the running processes.  
  
 
  df -h
 
  df -h
Line 78: Line 80:
 
  ifconfig -a
 
  ifconfig -a
  
Shows networking useful data, like current ip, netmasks and other statistics.  
+
Shows useful networking data, like current IP, netmasks and other statistics.  
  
 
  chmod
 
  chmod
  
chmod let you set files permissions. This utility is very important for people concerned about security, but it is useful also for coders, since you can set a script as executable with it .  
+
Lets you set files permissions. This utility is very important for people concerned about security, but it is also useful for coders, since you can set a script as executable with it.
  
 
  dmesg
 
  dmesg
  
Shows the messages resulting from the most recent system boot. It is useful for troubleshooting, since you can see which modules are loaded, which binaries are started and so on.  
+
Shows the messages resulting from the most recent system boot. This is useful for troubleshooting, since you can see which modules have been loaded, which binaries have started and so on.  
  
 
  sync
 
  sync
  
Thanks to this command your SD card lifespan will drastically improve, remember to launch it every time you turn Udoo off, or remove the power. Completes all pending input/output operations. It must be launched as root, or with sudo.  
+
Thanks to this command your SD card lifespan will drastically improve, remember to launch it every time before you turn UDOO off or remove the power. It completes all pending input/output operations. It must be launched as root, or with sudo.  
  
 
  reboot
 
  reboot
  
reboots the system  
+
Reboots the system.
  
 
  shutdown
 
  shutdown
  
shuts it down
+
Shuts it down.

Revision as of 07:53, 7 November 2014

Linux Command Line Interface (CLI from now on) could be at first glance discouraging for the average Joe, since nowadays we are only used to Graphic Interfaces. But don’t get let down, using a command line shell could be not only very useful, but also kind of funny. This guide will help you make your first steps in the command shell environment.

First, when could a Command Line Interface be useful for you?

  • Remote Connection via SSH: SSH remote connection allows you to interact with UDOO without physical access to it. SSH is available only with command line interface.
  • Using a minimal Linux Distribution without a graphical interface. Some Linux Distributions come without a Graphical User Interface in order to maximize available resources. Command line interface is your only bet in this scenario. Some power-users consider CLI the most convenient way to perform code execution and file-system operations. Even if you are not in this category, you may find that the CLI can be very fast when you get used to it.

To help you get started, here are some very basic Linux commands:

sudo

Your first ally, this command allows users to run programs with the security privileges of root, or superuser. Its name is a concatenation of “su” (super user) and “do”, or take action . So, if you get an error message saying “only root can do that”, just use the same command preceded with sudo.

sudo su

This enables root privileges once for all, without forcing you to type sudo everytime. It works until you close the shell you are working in.

sudo su touch

Creates an empty file

nano

Open an handy text editor. To save and exit, press “ctrl” and “x”, and press “y” for yes or “n” for no.

cat

Shows the content of a file, it speeds up file inspection for smaller files. e.g. cat /etc/hostname

ls

Lists the contents of the current folder.

cd

Changes current folder to specific folder.

cd..

Changes current folder to a higher folder level.

cd /

Changes current folder to root (top filesystem level)

rm

Deletes a file.

rm -rf

Deletes a folder.

mv

Moves a file or a folder. Useful for renaming also, e.g. mv myfile /myfolder/myfile and mv myfile mysecondfile

cp

Copies a file, e.g. cp myfile /home/ubuntu/

cp -R

Copies a folder, e.g. cp -R myfolder /home/ubuntu/myfolder

mkdir

Creates a folder

top

Top is a very useful utility, it basically gives you a complete overview of the system's status. It produces an ordered list of running processes selected by user-specified criteria. Top shows how much processing power and memory are being used, as well as other information about the running processes.

df -h

Shows used and available disk space, in megabytes.

ifconfig -a

Shows useful networking data, like current IP, netmasks and other statistics.

chmod

Lets you set files permissions. This utility is very important for people concerned about security, but it is also useful for coders, since you can set a script as executable with it.

dmesg

Shows the messages resulting from the most recent system boot. This is useful for troubleshooting, since you can see which modules have been loaded, which binaries have started and so on.

sync

Thanks to this command your SD card lifespan will drastically improve, remember to launch it every time before you turn UDOO off or remove the power. It completes all pending input/output operations. It must be launched as root, or with sudo.

reboot

Reboots the system.

shutdown

Shuts it down.