Common Linux Commands
To cover all the commands possible in Linux would take several books! Here I'm just going to list a few of the common ones and let you use your favourite search engine to find out the details:
|ls||List files (-and their attributes) in a given directory||$ ls|
$ ls -l /var/temp
|cd||Change the current directory to the one specified||$ cd|
$ cd ..
$ cd /var/temp
|pwd||Display the current directory path||$ pwd|
|more||Display the contents of a file, one page at a time. Press "SPACE" to show the next page or "q" to quit||$ more /var/tmp/myfile|
|chmod||Change the permissions on a file or directory||$ chmod 755 myfile|
|chown||Change the owner of a file or directory||$ chown fred:users myfile|
|vi||Edit the file in the "vi" editor||$ vi /var/tmp/myfile|
|df||List the filesystems on the system||$ df -h|
|echo||Print out the text specified||$ echo "hello $USER"|
|ps||List running processes||$ ps -ef|
|kill||Stop (abort) a running Process ID (PID)||$ kill 1036|
|grep||Search for a string in a file||$grep "fred" names.txt|
||||Known as a "pipe" : take output from one command as input to the next||$ps -ef | grep "root"|
|cp||Make a copy of an existing file||$ cp fred.txt bert.txt|
|mv||Rename or move an existing file||$ mv fred.txt /tmp/bert.txt|
|rm||Delete (remove) an existing file(s)||$ rm fred.txt bert.txt|
|mkdir||Create a directory||$ mkdir backupDir|
|rmdir||Delete (remove) a directory||$ rmdir backupDir|
Each of these commands can be used singly or in conjunction with each other (-see the chapter on I/O Redirection for details of the latter).
Every Linux command has a man (-short for manual) page: if you type "man <Linux command>" into a command line, it will print out lots of useful information. For example if you are unsure of the options used with the "ls" command, you can type:
$ man ls
LS(1) User Commands LS(1)
ls - list directory contents
ls [OPTION]... [FILE]...
List information about the FILEs (the current
directory by default). Sort entries alphabeti‐
cally if none of -cftuvSUX nor --sort.
Manual page ls(1) line 1
Man pages tend to be quite long and will be displayed a page at a time: hit the spacebar to display the next page or the "q" key to quit the listing and return to the prompt.
Note: you can also find man pages on the web!
Here's a extract from a simple command line session:
$ cd /home/fredb
$ mkdir tmp
>$ cd /home/fredb
$ cp /home/fredb/myfile.txt herfile.txt