Linux terminal commands


When it comes to working with Linux distributions for technical stuff, it's important to know these terminal commands which help alot in the long run working.😊

1. pwd — When you first open the terminal, you are in the home directory of your user. To know which directory you are in, you can use the “pwd” command. It gives us the absolute path, which means the path that starts from the root. The root is the base of the Linux file system. It is denoted by a forward slash( / ). The user directory is usually something like "/home/user".

2. ls — Use the "ls" command to know what files are in the directory you are in. You can see all the hidden files by using the command “ls -a”.

3. cd — Use the "cd" command to go to a directory. For example, if you are in the home folder, and you want to go to the downloads folder, then you can type in “cd Downloads”. Remember, this command is case sensitive, and you have to type in the name of the folder exactly as it is.To go back from a folder to the folder before that, you can type “cd ..” . The two dots represent back.

4. mkdir & rmdir — Use the mkdir command when you need to create a folder or a directory. To delete a directory containing files, use rm.

5. rm - Use the rm command to delete files and directories.  Use "rm -r" to delete just the directory.

6. touch — The touch command is used to create a file. It can be anything, from an empty txt file to an empty zip file. For example, “vijay.txt”.

7. man & --help — To know more about a command and how to use it, use the man command. It shows the manual pages of the command.

8. cp — Use the cp command to copy files through the command line. It takes two arguments: The first is the location of the file to be copied, the second is where to copy.

9. mv — Use the mv command to move files through the command line. We can also use the mv command to rename a file. For example, if we want to rename the file “hello-old” to “hello-new”, we can use “mv hello-old hello-new”. It takes the two arguments, just like the cp command.

10. locate — The locate command is used to locate a file in a Linux system, just like the search command in Windows. This command is useful when you don't know where a file is saved or the actual name of the file. Using the -i argument with the command helps to ignore the case (it doesn't matter if it is uppercase or lowercase). So, if you want a file that has the word “hello”, it gives the list of all the files in your Linux system containing the word "hello" when you type in “locate -i hello”. If you remember two words, you can separate them using an asterisk (*). For example, to locate a file containing the words "hello" and "this", you can use the command “locate -i *hello*this”.

Intermediate Commands

1. echo — The "echo" command helps us move some data, usually text into a file.

2. cat — Use the cat command to display the contents of a file. It is usually used to easily view programs.

3. nano, vi, jed — nano and vi are already installed text editors in the Linux command line. The nano command is a good text editor that denotes keywords with color and can recognize most languages. And vi is simpler than nano. You can create a new file or modify a file using this editor.

4. sudo — A widely used command in the Linux command line, sudo stands for "SuperUser Do". So, if you want any command to be done with administrative or root privileges, you can use the sudo command.

5. df — Use the df command to see the available disk space in each of the partitions in your system.

6. du — Use du to know the disk usage of a file in your system. If you want to know the disk usage for a particular folder or file in Linux, you can type in the command df and the name of the folder or file.

7. tar — Use tar to work with tarballs (or files compressed in a tarball archive) in the Linux command line. It has a long list of uses. It can be used to compress and uncompress different types of tar archives like .tar, .tar.gz, .tar.bz2,etc. It works on the basis of the arguments given to it.

8. zip, unzip — Use zip to compress files into a zip archive, and unzip to extract files from a zip archive.

9. uname — Use uname to show the information about the system your Linux distro is running.

10. apt-get — Use apt to work with packages in the Linux command line. Use apt-get to install packages. This requires root privileges, so use the sudo command with it.

11. chmod — Use chmod to make a file executable and to change the permissions granted to it in Linux.

12. hostname — Use hostname to know your name in your host or network. Basically, it displays your hostname and IP address. Just typing “hostname” gives the output. Typing in “hostname -I” gives you your IP address in your network.

13. ping — Use ping to check your connection to a server.

* These commands are pretty enough i guess!!
Learn these with practice.

regards,
vijay

Comments

Popular Posts