cat – Sends file contents to standard output. This is a way to list the contents of short files to the screen. It works well with piping.
Example: cat .bashrc
Description: Sends the contents of the “.bashrc” file to the screen.
cd – Changes the current working directory to /home. The ‘/’ indicates relative to root. No matter what directory you are in when you execute this command, the directory will be changed to “/home”.
Example: cd httpd
Description: Changes the current working directory to httpd, relative to the current location which is “/home”. The full path of the new working directory is “/home/httpd”.
cd .. – Moves to the parent directory of the current directory. This command will make
the current working directory as “/home”.
Cd ~ – Moves to the user’s home directory which is “/home/username”. The ‘~’ indicates the users home directory.
Cp – Copies files from one directory to another.
Example: cp myfile yourfileCopy
Description: The files “myfile” to the file “yourfile” in the current working directory. This command will create the file “yourfile” if it doesn’t exist. It will normally overwrite it without warning if exists.
Example: cp -i myfile yourfile
Description: With the “-i” option, if the file “yourfile” exists, you will be prompted before it is overwritten.
Example: cp -i /data/myfile
Description: Copies the file “/data/myfile” to the current working directory and names it “myfile”. It also prompts before overwriting the file.
Example: cp -dpr srcdir destdirCopy
Description: Copies all files from the directory “srcdir” to the directory “destdir” preserving links (-p option), file attributes (-p option), and copy recursively (-r option). With these options, a directory and all it contents can be copied to another directory.
dd – Disk duplicate. This command converts and copies a file.
Example: dd if=/dev/hdb1 of=/backup/
Description: “if” means input file, “of” means output file.
df – Shows the amount of disk space used on each mounted file system.
less – Allows the user to move page up and down through the file.
Example: less textfile
Description: Displays the contents of textfile.
ln – Creates a symbolic link to a file.
Example: ln -s test symlink
Description: Creates a symbolic link named symlink that points to the file test. Typing “ls -i test symlink” will show that the two files are different with different inodes. Typing “ls -l test symlink” will show that symlink points to the file test.
locate – A fast database driven file locator. This command builds the slocate database, taking several minutes to complete. It must be used before searching for files; however cron runs this command periodically on most systems.
Example: slocate -u whereis
Description: Lists all files whose names contain the string “whereis”.
logout – Logs the current user off the system.
ls – Lists files in the current working directory except those starting with ‘.’ and only shows the file name.
Example: ls -al
Description: Lists all files in the current working directory in long listing format, showing permissions, ownership, size, and time and date stamp.
more – Allows file contents or piped output to be sent to the screen, one page at a time.
Example: more /etc/profile
Description: Lists the contents of the “/etc/profile” file to the screen, one page at a time.
Example: -al |more
Description: Performs a directory listing of all files and pipes the output of the listing through more. If the directory listing is longer than a page, it will be listed one page at a time.
mv – Moves or renames files.
Example: mv -i myfile yourfile
Description: Moves the file from “myfile” to “yourfile”. This effectively changes the name of “myfile” to “yourfile”.
Example: mv -i /data/myfile
Description: Moved the file “myfile” from the directory “/data” to the current working directory.
pwd – Shows the name of the current working directory.
Example: more /etc/profile
Description: Lists the contents of the “/etc/profile” file to the screen, one page at a time.
shutdown – Shuts the system down.
Example: shutdown -h now
Description: Shuts the system down to halt immediately.
Example: shutdown -r now
Description: Shuts the system down immediately, and the system reboots.
whereis – Shows where the binary, source and manual page files are for a command.