Skip to main content

Basic, intermediate, advanced commands for linux


Basic commands:- 

pwd command

Use the pwd command to find out the path of the current working directory (folder) you’re in.

cd command

To navigate through the Linux files and directories, use the cd command.

 ls command

The ls command is used to view the contents of a directory. 

cat command

cat (short for concatenate) is one of the most frequently used commands in Linux. 

cp command

Use the cp command to copy files from the current directory to a different directory. For instance, the command cp scenery.jpg.

rmdir command

If you need to delete a directory, use the rmdir command. However, rmdir only allows you to delete empty directories.

rm command

The rm command is used to delete directories and the contents within them. If you only want to delete the directory — as an alternative to rmdir — use rm -r.

touch command

The touch command allows you to create a blank new file through the Linux command line.

locate command

You can use this command to locate a file, just like the search command in Windows.

find command

Similar to the locate command, using find also searches for files and directories. 

grep command

Another basic Linux command that is undoubtedly helpful for everyday use is grep. It lets you search through all the text in a given file

sudo command

Short for “SuperUser Do”, this command enables you to perform tasks that require administrative or root permissions.

df command

Use df command to get a report on the system’s disk space usage, shown in percentage and KBs.

du command

If you want to check how much space a file or a directory takes, the du (Disk Usage) command is the answer.

 head command

The head command is used to view the first lines of any text file. By default, it will show the first ten lines, but you can change this number to your liking.

 tail command 

This one has a similar function to the head command, but instead of showing the first lines, the tail command will display the last ten lines of a text file. 

 diff command

Short for difference, the diff command compares the contents of two files line by line. 

kill command

If you have an unresponsive program, you can terminate it manually by using the kill command. 

 ping command

Use the ping command to check your connectivity status to a server.

wget command

The Linux command line is super useful — you can even download files from the internet with the help of the wget command. 

uname command

The uname command, short for Unix Name, will print detailed information about your Linux system like the machine name, operating system, kernel, and so on.

 top command 

As a terminal equivalent to Task Manager in Windows, the top command will display a list of running processes and how much CPU each process uses.

 history command

When you’ve been using Linux for a certain period of time, you’ll quickly notice that you can run hundreds of commands every day.


Intermediate commands:-

grep


grep prints the lines from a file or input stream that match an expression. For example, if you want to print the lines in the /etc/passwd file that contain the text root, use this command


more and less


When a command's output is long, it can scroll off the top of the screen, and it's annoying to use a scrollbar to view such output because you have to move your hands around. You sometimes may also want to look at a large text file without starting a text editor. Two standard commands for text navigation are more and less.

pwd


This program's name stands for "print working directory," and the command outputs the current working directory.

diff


To see the differences between two text files, use diff:


find


It's frustrating when you know that a certain file is in a directory tree somewhere, and you just don't know where. Run find to find file in dir:


head and tail


To quickly view a portion of a file or stream, use the head and tail commands.

 

sort


The sort command quickly puts the lines of a text file in alphanumeric order. If the file's lines start with numbers, and you want to sort in numeric order, use the -n option. The -r option reverses the order of the sort.


Advanced commands:-


find 

Search for files in the given directory, hierarchically starting at the parent directory and moving to sub-directories.


grep

Search for files in the given directory, hierarchically starting at the parent directory and moving to sub-directories.

man

The ‘man‘ is the system’s manual pager. Man provides online documentation for all the possible options with a command and its usages.


ps

ps (Process) gives the status of running processes with a unique Id called PID.


kill

The kill() function sends a signal to a process or process group specified by pid.


whereis

The ‘whereis‘ command is used to locate the BinarySources and Manual Pages of the command. For example, to locate the BinarySources and Manual Pages of the command ‘ls‘ and ‘kill‘.

service

The ‘service‘ command controls the StartingStopping or Restarting of a ‘service‘.


alais 

alias is a built in shell command that lets you assign name for a long command or frequently used command.

I uses ‘ls -l‘ command frequently, which includes 5 characters including space. Hence I created an alias for this to ‘l‘.


 


Comments

Popular Posts