Introduction to Linux System Commands
Linux is an open source operating system which was developed by Linus Torvalds. Being an open source operating system the source code can be modified by different users and variations for this code can be created. These different variations are known as distributions and they can be used in different computers and other devices. All versions of Linux manage hardware, their resources and also help in launching different applications. A distribution of Linux mainly consists of a kernel, system utilities, programs and tools which can be used for downloading and installing different software updates.
Basic Linux System Commands
Following are the very basic commands which are similar to UNIX and which can be used to run the OS.
1. pwd: Whenever a terminal is opened a user is supposed to be at some path. To know the current path of the directory this command is used. It specifies the entire path of where the user is currently present. It stands for ‘present working directory’. It gives the absolute path which consists of a root, which is the basis of any Linux file system.
2. ls: This command is the abbreviation for a list. It lists down the files and directories that are present in a particular directory. It can be used with many combinations and accordingly the results can be retrieved. All hidden files can be seen by making use of ls -a. Also, the latest files can be found by making use of ls -lrt.
3. cd: This command of Linux system is used to go to a particular directory. Let’s say that you are in the home Folder and maybe you would like to go to some project folder. You can just write the cd ‘project name’. You will be taken to that folder and you can view the files and directories present in this folder.
This command will take you to a sqoop folder.
4. touch: The touch command helps in creating a file at any particular path. This file can be anything from an empty txt file to an empty zip file. As an example, let us create a file named ‘test’.
Here test.txt is successfully created by making use of touch command.
5. man or – help: This Linux system command provides a help guide or manual which helps in getting the necessary instructions. It shows the manual page of the command. The command when hit which ways the commands can be used when a man is used with any particular command.
6. locate: To find a file in the Linux system the locate command is used. It is very similar to search command in Windows. This command gets you the path where it is saved or the actual name of the file. In addition to this if ‘-i’ argument is used then it will ignore the case of the filename. You can also make use of ‘*’ if you do not remember the complete name of the file.
7. sudo: It is widely used in Linux. If a user wants to perform any task with administrative privileges then sudo command can be used. It stands for ‘SuperUser Do’. A short form of this command that is ‘su’ can be used.
8. cp: This command can be used to copy a file from a particular source directory to a destination directory. The first location must specify the file from where a file has to be copied and the destination must be on the second location.
9. mv: This Linux system command is used to directly move the file to a destination folder. It deletes the copy from the source path and puts the file to the destination path.
10. mkdir and rmdir: These commands are used to create directories and remove directories respectively. These directories can further store files and other directories. To remove a directory the directory should be empty.
Intermediate Linux System Commands
Let us now have a look at the intermediate commands.
1. echo: This command of Linux system is useful when a user needs to move data. It is usually created for text files.
echo hello, my name is Ann >> new.txt
2. cat: This command is used to display the contents of a file. It will show all the contents that are present in that file.
3. nano, vi: This command is the text editors that are already present in the Linux system. You can use these editors whenever required. A new file can be created and modifications can be made in the same using these editors.
4. tail: This Linux system command prints the last lines of any file. By default, the tail command displays the last 10 lines on the standard output. In order to see more lines, a user can specify tail –n where n is the number of lines you would like to be displayed.
5. less: This command displays pages in a file. It is mostly useful for checking log files and files which have large files of data. It prints the file page by page.
6. tar: This Linux system command is used to create views and it also helps in extracting tar archives.
7. whatis: This command provides a single line description for any given command and tells what the command does.
8. ping: This Linux system command enables you to a remote server.
9. free: This command lets you know the free, used and swap memory that is available on your system.
10. ps: It displays the processes that are running on the system
Advanced Linux System Commands
Let us take a look at advanced commands.
1. Grep: This command is used to search a pattern in the given file. The given file contains a match to the given strings or words. In order to ignore word case and all other combinations then ‘– I ’ should be used. Also, a user can search recursively and read all files in each specified directory. Also the different options like –w for word count, -c for a count and – color for colored output can be used.
2. Service: The service command helps in starting, stopping and restarting the service. This command can help in doing these services and bring changes to effect.
Tips and Tricks to use
- You can make use of clear to clear the terminal
- TAB can be used to fill up the terminal. Eg if you know the start of a directory then press ‘cd’ and starting of the folder name and tab. It will bring up the entire folder name.
- Ctrl+Z can be used to force stop any process.
Linux is an operating system when helps to work with files and directories very efficiently. It helps in shell scripting and performing all operations easily.
This has been a guide to Linux System Commands. Here we have discussed basic, intermediate as well as advanced Linux System Commands along with tips and tricks to use. You may also look at the following article to learn more –