50 Linux commands developers should Know

Share

1. Command Name : ls

Syntax: ls [option] [directory/file]

Usage: The ls command allows the user to view the contents of a directory. It lists the files and directories.

Command Used:

ls: This command is used to list files and folders in the current directory.

Output :

2. Command Name : cd

Syntax: cd [directory/file]

Usage: This cd command allows the user to navigate through Linux files and directories.

Command Used:

cd ..: This command is used to move one directory up.

cd: This command is used to move to the home directory.

cd -: This command is used to move to the previous directory.

cd [directory]: This command is used to move to a specific directory.

Output :

3. Command Name : grep

Syntax: grep ‘word’ [filename]

Usage: It is used to search for specific words in a specified text file or all the text files in any directory.

Command Used:

grep ‘word’ [filename] – It is used to find specific words in a specified text file.

grep -i ‘word’ [filename] – It is used to perform a case insensitive search for words in a text file.

grep -R ‘word’ – It is used to search for the specific word in all the text files in the current working directory.

Output :

4. Command Name: Sudo

Syntax: sudo [command]

Usage : 

Sudo stands for ‘SuperUser Do’. It enables users to run some commands as a super user or System Administrator that normal users cannot do. 

Command Used:

sudo apt update – apt commands can only be executed by admin. sudo command lets us execute this command.

5. Command Name: pwd

Syntax: pwd

Usage: It prints the current working directory for the user to see.

Command Used:

pwd – It prints the current working directory.

Output :

6. Command Name : mv Syntax: mv [filename] [directory]

Usage : It is used to move file from one directory to another directory and to rename files.

Command Used:

mv [file] [directory] : It is used to transfer specified file to the specified directory.

mv [old_file_name] [new_file_name] : It is used to rename file.

Output :

7. Command Name :cp

Syntax: cp [source_file] [destination_file]

Usage: It is used to copy the contents of one file to another file.

Command Used:  cp [source_file] [destination_file] : It is used to copy contents in source text file to an      empty destination file.

Output :

8. Command Name : rm Syntax: rm [filename]

Usage:  It is used to delete files.

Command Used:

rm [filename]: This command deletes the specified file.

rm — [-filename]: This is used in case the file name starts with a ‘-’ sign.

Output :

9. Command Name : mkdir

Syntax: mkdir[directoryname]

Usage: This command is used to create a sub-directory in the current working directory.

Command Used: mkdir[directoryname] 

Output :

10. Command Name: rmdir

Syntax: rmdir [directoryname]

Usage:   This command is used to delete a directory provided that it is empty.

Command Used: rmdir [directoryname]


11. Command Name : chmod

Syntax: chmod [options][permissions][filename]

Usage: The chmod command is used to set the permission of files and directories.

Command Used:

chmod [permission] [filename] – This command is used to change the permissions of a file.

chmod -R [permission] [directory] – This command is used to change the permissions of a directory.

Output :

12. Command Name : cat Syntax: cat <filename.extension

Usage: This command is used to display the contents of a file.

Command Used:

cat > [Filename] – This command is used to create a new file.

cat [old_filename] > [new_filename] – This command is used to copy the contents of one file to another.

13. Command Name : chown

Syntax: chown [owner_name] [file_name]

Usage: This command can change the ownership of a file or folder to the specified username.

Command Used: chown [owner_name] [file_name] – This command changes the ownership of the specified file.

14. Command Name: echo Syntax: echo [string]

Usage: The echo command displays a text or a string to the standard output or a file.

Command Used: echo [string] – This command displays a string to the standard output or a file.


15. Command Name: wc

Syntax: wc [file]

Usage: The command is used to count the number of lines, words, bytes, and even characters and bytes in a text file.

Command Used:

 wc [file] – This command is used to count the number of lines, words, bytes, and characters and bytes in a text file.

wc [file] [file] – This command shows all the above-mentioned things of both the files listed for comparison.

16. Command Name: man

Syntax: man [command]

Usage: This command prints documentation for any Linux command on the system.

Command Used: man [command] – This command prints the documentation for any Linux command on the system.

17. Syntax: history

Usage: The history command shows the previously used commands.

Command Used: history – This command shows the previously used commands.


18. Command Name: clear Syntax: clear

Usage : The clear command clears the terminal screen.

Command Used: clear – This command clears the terminal screen.

 Output :

19. Command Name : touch Syntax: touch [filename]

Usage : This command is used to create a new blank file.

Command Used: touch[filename] – This command creates a new blank file.


20. Command Name : locate Syntax: locate [filename]

Usage : Locate command helps in locating file for the users.

Command Used: locate [filename] – This command helps in locating files for the users.

Output :

21. Command Name : df Syntax: df [file]

Uses : This command is used to get the information related to file systems about total space and available space.

Command Used: df [file] – This command is used to get the information related to file systems about total space and available space.

Output :

22. Command Name: du Syntax: du [option]

Usage : The du command shows how much space a file or a directory takes.

Command Used:

du -h – This command shows how much space a file or directory takes in human-readable form.

du -s – This command gives a summary of the output total size.

Output :

23. Command Name : uname Syntax: uname [option]

Usage : This command prints detailed information about your Linux system.

Command Used:

uname -a – This option displays everything.

uname -v – This option displays the kernel information.

uname -s – This option displays kernel version of the system.

uname -r – This option displays the kernel release.

24. Command Name : passwd

Syntax: passwd

Usage : This command is used to change the password of the current user without the sudo command.

Command Used: passwd – This command is used to change the password.

 Output :

25. Command Name : useradd

Syntax: useradd [username]

Usage : It is used to add a user.

Command Used: useradd [username] – This command is used to add user in Linux.

Output :

26. Command Name : userdel

Syntax: userdel [username]

Usage : It is used to delete a user.

Command Used: userdel [username] – This command is used to delete user in Linux.

27. Command Name : apt-get

Syntax: apt-get [option] [command]

Usage: It is a command line tool used to interact with the APT(Advanced package tool) Library.

Command Used:

apt-get update – It is used to resynchronize the package index files and update the package repository to the latest version.

apt-get install [PackageName] – This command is used to install packages in the APT library.

apt-get remove [PackageName] – This command is used to remove packages installed on your device.

29. Command Name : ping

Syntax: ping [DomainName]

Usage : It is used to check your connection to a server.

Command Used: ping [DomainName] – This command is used to check the device’s connection to a server.

30. Command Name : find

Syntax: find [options] [path..] [expression]

Usage : It searches for files and directories in a directory hierarchy based on a user-given expression and can perform user-specified action on each matched file.

Command Used: find [options] [path…] [expression] – This command helps look for files and directories in a directory hierarchy on a very specific manner.

Output :

31. Command Name : head

Syntax: head [FileName]

Usage : This command allows users to view the first lines of any text file.

Command Used: head[FileName] – This command is used to view first few lines of a text file.

32. Command Name : rename

Syntax: rename [option] perlexpr [files]

Usage : This command renames the named files according to the regular expression perlexpr.

Command Used:

rename -v perlexpr [files] – This command prints the name of files successfully renamed.

rename -n perlexpr [files] – This command shows what files should be renamed.

rename -f perlexpr [files] – This command overwrites the existing files.


33. Command Name : tail Syntax: tail [FileName]

Usage : This command shows the last ten lines of a text file.

Command Used: tail [FileName] – This command is used to display the last ten lines of a text file.

Output :

34. Command Name : tac

Syntax: tac [FileName]

Usage : This command displays the contents of a text file in reverse.

Command Used: tac [FileName] – This command displayed the contents of a text file in reverse.

Output:

35. Command Name : comm

Syntax: comm [file1] [file2]

Usage : This command is used to compare two files for similarity and differences.

Command Used: comm [file1] [file2] – This command is used to find similarities and differences between two files.

36. Command Name : cut

Syntax: cut [option] [FileName]

Usage : The cut command is used to extract the specific portion of text in a file.

Command Used:

cut -b [FileName] – This command is used to extract bytes from the file.

cut -f [FileName] – This command is used to extract by specifying a field, a set of fields, or a range of fields. This is the most commonly used option.

cut -c [FileName] – This command is used to extract by specifying a character, a set of characters, or a range of characters.

37. Command Name : sort

Syntax: sort [file]

Usage : Sort command in Linux is used to arrange the record in a specific order.

Command Used: sort [FileName] – This command is used to arrange records of a text file in a specific order.

38. Command Name : date

Syntax: date

Usage: It displays the current date and time.

Command Used: date – This command displays the current date and time.

 

39. Command Name : cal

Syntax: cal [Month] [Year]

Usage : This command displays a calendar of a given year or month depending on the options passed.

Command Used:

cal – This command displays the calender of the current month.

cal [Month] [Year] – This command displays the calendar of the month and year specified.

40. Command Name : time

Syntax: time [command]

Usage : The time command is used to determine how long a given command takes to run.

Command Used: time [command] – This command displays the amount of time taken by a command to run.

Output :


41. Command Name : host

Syntax: host [option] [DomainName]

Usage : The host command in Linux allows the user to lookup DNS (Domain Name System).

Command Used:

host – This commands prints the list of options for the host command.

host [DomainName] – This command prints out the IP address of the domain name.

host [IPaddress] – This command prints out the domain name of the IP address.

host -a [DomainName]– This command prints IP address of any Domain Name similar to that provided by the user.

Output :

42. Command Name : id

Syntax: id [username]

Usage : id is a command-line utility that prints the real and effective user and group IDs.

Command Used:

id [UserName] – This command prints the information about the specified user.

id – This command prints the information about the current user.

Output :

43. Command Name : ps

Syntax: ps

Usage : This command is used to list the currently running processes and display information about those processes.

Command Used: ps – This command is used to list all the currently running processes and display their information.

44. Command Name : top

Syntax: top

Usage : This command reports system information like running processes and resource usage.

Command Used: top – It reports system information and shows processor activity and kernel-managed tasks in real-time.

Output :

45. Command Name : kill

Syntax: kill [Signal] [ProcessID]

Usage : This command is used to kill process manually.

Command Used:

kill -l – This command is used to get list of all signals.

kill -9 [ProcessID] – This command kills the process specified.

Output :

46. Command Name : pkill

Syntax: pkill [option] [pattern]

Usage : The command-line utility pkill kills program processes based on the parameters you specify.

Command Used: pkill [command] – This command is used to kill certain commands running in the system.

47. Command Name : killall Syntax: killall [Options]

Usage : This command sends a signal to all processes running any of the specified commands.

Command Used: killall [options] – This command kills all processes according to the specific options.

48. Command Name : bg Syntax: bg [job]

Usage : This command is used to to send a service, which is working in the foreground, to the background using job control.

Command Used: bg [job] – This command sends the program working in the foreground to the background.

Output :

49. Command Name : fg

Syntax: fg [job]

Usage : This command moves a background process on your current Linux shell to the foreground.

Command Used: fg[job] – This command moves a background process to the foreground.

Output :

50. Command Name : tar

Syntax: tar [options] [archive_file] [file or directory to be archived] Usage : This command is used for creating & extracting archive files.

Command Used:

tar -czvf [archive file] [file or directory to be archived] – This command creates a tar of the file or directory specified.

tar -tf [archive file] – This command lists the contents of the tar file.

51. Command Name: gzip

Syntax: This command helps us reduce the size of a file and keep the original file mode, ownership, and timestamp.

Usage : gzip [option] [File] 

Command Used:

gzip [FileName] – This command deletes the original file while creating a zip file.

gzip -k [FileName] – This command keeps the original file while the zip file is named the same.

gzip -c [FileName] > [Zip Name]– This command stores the files in a specific gzip file.

Read: Web development setup in Linux

Open Source: https://github.com/torvalds/linux

Share
Sudeep Mishra

Sudeep Mishra

Healing

%d bloggers like this: