cat – Shows the contents of files to the screen.
Usage:
Also this command can be used to count the number of lines, words and characters in a file:
- number of lines
- number of words
- number of characters
To search for a word in a file you can use:
cd – Change directory
the ‘cd’ command should be used followed by the name of a directory including the full path to that directory. If you execute ‘cd’ without arguments the working directory will be switched to your ‘home directory’.
Usage:
To move one directory up, you can use the shortcut command:
cp – Copy files and directories
Usage:
Example:
With this command you will make a copy of ‘file’ located in the ‘/root’ directory to the ‘/tmp’ directory if it does not exist. It will overwrite it in case the ‘file’ already exists.
df – Check the amount of free disk space on the filesystems.
Usage:
To get a more easily readable (human-readable) output of the command use:
free – Gives information about used and free memory and swap space on a Linux machine.
Usage:
The -b option shows the amount of memory in bytes; the -k option (set by default) shows it in kilobytes; the -m options shows it in megabytes.
rm – Removes directories, files, symbolic links, etc. from the filesystem.
Usage:
Most common options for this command are:
-f : ignore nonexistent files, never prompt
-r : remove directories and their contents recursively
-v : explain what is being removed
Note: Always double check before removing any file or directory.
ls – Displays a list of files and directories in a specific directory.
If you enter just ‘ls’ without specifying a directory, it will display a list of files and directories in the working directory.
Usage:
Most common options for this command are:
-a : shows all files and folders including the hidden ones.
-l : use a long listing format
mv – Moves files and directories from one directory to another or renames a file or directory.
Usage:
Move ‘file’ from ‘/root’ to ‘/tmp’ directory
Rename ‘file1′ to ‘file2′
passwd – change user password
Usage:
If you execute just ‘passwd’ without specifying the username, you will change your root password.
Note: Never use passwords that are easily guessable, such as passwords based upon names, street addresses, dictionary words, significant dates, etc… A strong password consists of a combination of letters (both upper and lower case), numbers and special characters and it should be at least 8 characters long.
mkdir – Creates directory(ies) if they don’t already exist
Usage:
Example: