I was a window user, I never thought to use Linux in my life time. But Suddenly it changed my world and I don't want to go back to the windows because I fell in love with linux.
I am not a system admin now but I work on few Linux distribution which made me realized that whoever is going to learn Linux, they should know these basic Linux commands, which will help them to save few times and practice.
mkdir stands for make directory i.e. this command is responsible to create directories.
ls stands for list i.e. list the names of files and directories in current working directory.
There are various options which support ls command. Listing few of them in below.
ls -a : list all the files including hidden files. even though it include "." and ".." files.
- ls -A : list all the files including hidden files except "." and ".." files.
- ls -r: list the files in descending order name excluding hidden files.
- ls -R: list the files recursively and it shows the files inside directories.
- ls -l: list the files in long format i.e. name of each file, owner name, group name, size, index number, timestamp, permission etc.
- ls -g: list the files in long format but without owner name.
- ls -o: list the files in long format but without group name.
- ls -s: list the files with their sizes.
- ls -S: sort the files with their sizes.
- ls -i: list the files with their index numbers.
- ls -t: sort the files with time, latest should be at top.
- ls -p: append "/" to directories.
- ls -d */: list the directories
- ls -ltr: we can merge the above command together based on requirements. This is representing that list of all the files in long format, sort the files with modification time, in descending order.
cd full form is change directory. so it's used to change the shell directory.
cd [Directory Name]
But while going back to the parent directory of current directory, need to use below commands
While going back to the parent's of parent's directory, need to use below commands.
Based on the requirements we can add more ".." and "/" after cd command.
lsof stands for List Of Open File i.e. this command provide the information of list of opened files and opened for which process.
lsof [OPTIONS][USER NAME]
- Provided $lsof -u [USER NAME] command to see the opened file for specific user.
It gives continuous output in full screen mode with 2.0s interval.
Provided command watch date in below example
df stands for disk free i.e. it is used to show information about file system's total space and available space.
- If no file name is provided then it displays space available and used on all current mounted file systems.
- If file name is provided then it display space available and used on that particular file.
Provides the details of currently logged in user information.
- Login name of the users
- Terminal Line Number
- Login Time of the user
- Remote hostname of the user
Use to download the files from the server using HTTP,HTTPS,FTP protocols.
Use to see the information of user who is logged in and what they are doing.
The header provide the information of current time, how long system is running, how many users logged in and load average for past 1, 5 and 15 mins.
Other than these it display each user- login name, tty, remote host, login time, idle time, JCPU , PCPU and the command line of their current process.
w [OPTIONS] USER ...
wc stands for word count i.e. it is used for counting purpose.
It counts the number of lines, number of words, number of characters.
wc [OPTIONS]... [FILE]...
First column represent number of lines present in specific file, second column represent the number of words present in specific file, third column represent number of character presents and fourth column represents the name of the file.
lshw stands for list of hardware i.e. it displays details of system's hardware information. To access this command we should be a super user.
lshw [FORMAT]... [OPTIONS]...
Here format can be html, xml, json, short, businfo.
- It provides the full hardware information.
- It list the hardware info in compact format.
man stands for Manual i.e. it is used to display user manual for any command.
It provides details of command which includes : NAME, SYNOPSIS, DESCRIPTION, OPTIONS, EXIT STATUS, RETURN VALUES, NOTES, FILES, EXAMPLES, AUTHOR, REPORTING BUGS, COPYRIGHT and SEE ALSO.
man[OPTION]... [COMMAND NAME]...
- Provided $man lshw command without option and shown the whole manual of the specified command name.
- Provided $man -w [COMMAND NAME] command with option and shown the location of the manual page for the specified command name.
cat stands for concatenate. It reads data from the files and give their output. It also helps us to create file, view files, concatenate files.
- Provided $cat [file_name] command to get the output whatever is inside the file.
- Provided cat >[file_name] command to create the file and at the same time you can provide the text inside the file. After that you can exit using Ctrl+D.
rm stands for remove. remove commands can remove the files, directories etc. But by default it doesn't remove directories. But Be careful of these commands.
- Provided $rm [FILE NAME] command to remove specified file name.
$rm -r: remove directories recursively.
$rm -f: remove Read only file without permission.
$rm -rf. : Force deletion of Current folder and sub folders.
$rm -rf/ : Force deletion of Everything in root directory.
$rm -rf* : Force deletion of Everything in current directory.
$rm -rf [DIRECTORY NAME] : Force deletion of Specified Directory Name. It deletes everything whatever present inside of the directories.
$rmdir [DIRECTORY NAME]: Remove the Specified Directory Name. If directories content files or folders, this command unable to delete directories.
pwd stands for Print Working Directory. It prints path of the working directory, starting from the root.
mv stands for Move i.e. it moves file or files or directories from one place to another place.
mv [OPTION] [Source] [Destination]
- Provided $mv [file1] [file2] command, which is responsible to rename the file1 to file2 and override the file2 value with file1 value.
- Provided $mv -b [file1] [file2] command, -b is responsible to take the backup of overridden file value(file2). It creates a backup file with tilde (~) character append with it.
You can use --help option with any of the command to know more about the commands.