sudo: This command executes only that command with superuser privileges.
ls: This command is used to list the contents of a directory.
if you run ls -l, it will show the permissions, owner, size, and last modified date for each file in the directory.
3. pwd: This command will print your directory location, where you currently working.
4. cat: This is used to concatenate and display files on the terminal. It can also be used to modify existing ones.
cat -b: This adds line numbers to non-blank lines.
cat -n: This adds line numbers to all lines.
cat -s: This squeezes blank lines into one line.
cat âE: This shows $ at the end of the line.
5. vim: This is a text editor used in Linux. It stands for âVi Improvedâ.
Mostly used modes in VIM:
Normal mode: This is the default mode in which vim starts. In normal mode, you can use various commands to navigate and edit the text.
Insert mode: In insert mode, you can type text into the file. To enter insert mode, press the "i" key. To exit insert mode and return to normal mode, press the "Esc" key.
Command mode: In command mode, you can enter commands to perform various actions, such as saving the file or quitting vim. To enter command mode, press the ":" key.
6. grep: This command searches for a particular string/ word in a text file. This is similar to âCtrl+Fâ but executed via a CLI.
This would print all of the lines in âchxtan.txtâ that contain the word âThis".
7. sort: This command is used to sort the results of search either alphabetically or numerically. It also sorts files and directories.
sort -r: the flag returns the results in reverse order.
sort -f: the flag does case-insensitive sorting.
sort -n: the flag returns the results as per numerical order.
8. tail: This command prints the last N number of data of the given input. By default, it prints 10 lines.
We can specify the number of lines, that we want to display.
9. chmod: This command is used to change the access permissions of files and directories.
For example: Following âchmodâ command will give the user permission to read, write and execute a file.
10. chown: This command is used to change the file Owner or group.
Here, below the ownership of âChetan.txtâ file got changed to root.
- ping â This command will ping a host and check if it is responding.
12. isof: It is used to display a list of all the open files on a Linux system.
13. ifconfig: This is used to configure the kernel-resident network interfaces.
14. id: This is used to find out user and group names and numeric IDâs (UID or group ID) of the current user or any other user in the server.
Syntax: id <option> <user_name>
15. cut: This command is used to extract specific fields or columns from a file or standard input.
It is often combined with other commands, such as sort, uniq, and grep, to perform more complex text-processing tasks.
16. sed: This is used to perform basic text transformations on an input file. It stands for "stream editor" and is a powerful tool for editing text files or streams in a Linux environment.
17. diff: This command is used to find the difference between two files.
18. history: This command is used to view the previously executed command.
âHistory 10â â Will give you the last 10 executed commands.
19. find: This is used to find files and directories and perform subsequent operations on them.
In the below command, it will search in the present working directory and its subdirectories and print the name of the file that have â.txtâ file extension.
20. free: This command displays the total amount of free space available along with the amount of memory used and swap memory in the system, and also the buffers used by the kernel.
21. ssh user@host â connect to the host as a user.
22. ssh-keygen: This command is used to generate a public/private authentication key pair.
This process of authentication allows the user to connect remote server without providing a password.
(This authentication method we will use to authenticate the server with Jenkins while deploying CI/CD pipelines).
23. nslookup: This stands for âName server Lookupâ. This is a tool for checking DNS hostname to Ip or Ip to Hostname. This is very helpful while troubleshooting.
24. curl: Curl is a tool used for transferring data to or from a server, using various protocols, such as HTTP, HTTPS, FTP, and more. Basic example:
Syntax: curl <url>
-o: It will save downloaded file on the local machine with the name provided in parameters.
25. Tr: Tr stands for translation. This command is for translating or deleting characters.
26. apt-get: This command is used to install, update, and remove packages, as well as to manage the package repository sources.
Here are some common apt-get commands:
apt-get update: This updates the package index files from the package repositories listed in the /etc/apt/sources.list file. This is usually the first command you should run after adding a new repository or package to your system.
apt-get upgrade: This installs newer versions of packages that are already installed on the system. It will also remove any packages that are no longer required.
apt-get install: This installs one or more packages. For example, to install the nano text editor, you would run apt-get install nano.
apt-get remove: This removes one or more packages, but it does not remove the configuration files for the package.
apt-get purge: This removes one or more packages and their configuration files.
apt-get autoremove: This removes packages that were installed as dependencies but are no longer needed.
27. df, du:
Df (disk free) command will have an account of available disk space, used by file system.
Du (disk usage) command reports the size of directory tree including all the content.
28. htop: This command is used to monitor the systemâs resources and processes that are running in real time.
29. ps: We use ps command to check the unique id behind every process.
a = show processes for all users
u = display the processâs user/owner
x = also show processes not attached to a terminal
30. kill: This command is used to terminate processes manually. This command basically, will send a signal that terminates it.
31. TNC: This is âTest Network Connectionâ command. Mostly used command while troubleshooting. It displays diagnostic information for a connection.
Command: tnc <server_name> -port <port>