Tutorial: Commonly used Linux commands on P2C

posted Oct 7, 2014, 1:28 AM by SRGICS UPLB   [ updated Jun 4, 2015, 12:27 AM ]
Command format:

$<command name> <option 1>..<option n> <parameter 1>..<parameter m>

Example: Display the contents of the /etc directory with detailed information.

$ls -l /etc

where:
   <command name> = ls
   <option 1> = -l
   <parameter 1> = /etc

The following commands are used frequently:

1. ls - list the contents of a directory
Example: Show a list of files in the current directory.
$ls
2. cd - change to a directory
Example: Go to the 'documents' folder inside the current directory.
$cd documents
Example: Go to your home directory.
$cd ~
Example: Go to the parent directory.
$cd ..
Example: Go to the directory two levels above the current directory.
$cd ../../
Example: Go to the web server document root.
$cd /vaw/www
3. mkdir - create a new directory
Example: Create a directory named 'images'.
$mkdir images
4. man - display information on a command. Press 'q' to exit.
Example: Show help information on the ls command.
$man ls
5. pwd - display the current working directory.
Example:
$pwd
6. cp - copies a file.
Example: Copy 'hello.txt' to 'hello.txt.bak'
$cp hello.txt hello.txt.bak
7. rm - delete a file
Example: Delete the file 'hello.txt'
$rm hello.txt
8. rmdir - delete a directory. The directory must have no files. Use rm to delete files.
Example: Delete the 'images' directory
$rmdir images
9. clear - clear the screen.
Example:
$clear
10. cat - display the contents of a file.
Example: Display the contents of the file 'hello.txt'.
$cat hello.txt
11. less - display, with scrolling, the contents of a file. Press 'q' to exit.
Example:
$less hello.txt
12. nano - text editor. 'Ctrl+O' to save, 'Ctrl+X' to exit.
Example:
$nano hello.txt
13. df - checks disk space
Example:
$df -h
Comments