Hey Guys !!!! Here, I am up with another blog on Linux basic commands.
Let us start by discussing what is Linux, its importance and why it is important to know the basics of Linux?
Linux is an open source operating system(OS). It is a free and open source operating system. What makes Linux different from other operating system is that unlike windows which a proprietary operating system which means users have to work in the relatively closed environment. There are various flavors of Linux which are listed below:
- Ubuntu Linux
- Red Hat Enterprise Linux
- Linux Mint
Linux is mostly used in a server(there are various reasons for using them for a server because they are fast, free and most importantly secure). Linux has completely open source kernel(kernel is basically the central part of an operating system). Windows server costs very high.
Linux has a bit of learning curve, however, patience and perseverance will lead to be an expert in Linux. Here are some basic Linux commands that one should know:
1. ls: This command is used to list down the files in the directory you are in. The ls-a command can be used to list down all the hidden files.
2. cd: This command is used to change the directory.
3. mkdir & rmdir: mkdir is used to create a folder or a directory using a command prompt. For example, if you want to make a directory named “techdenovo”, then by using the command mkdir techdenovo you can make a new folder named techdenovo.
4. cp: cp simply stands for a copy. This command is used to copy the files or a group of files. This command requires at least two file name in its arguments. The syntax of cp command is as follows:
- cp source destination
- cp source directory
- When you want to copy multiple files use the command below:
- cp source_1 source_2 source_n directory
5. rm: This command is used to delete the files or directory. But the turning point comes here that the rm command cannot be directly used to remove directories. Instead, we use recursive(-R or -r) option to remove all the content of a directory along with the directory itself.
6. man & –help: Man command provides you a helping hand. Man command gives you more information about a command. It gives you a detailed information about a command(opens a manual page of a given command). The page then gives all the relevant information about that command like its name, synopsis, description etc.
7. touch: This command is used to create a new and empty file. It is also used to modify dates and time of most recent access and modification on existing files.
8. mv: This command is used to move files using a command line. We can also use this command to rename files and directories. The syntax for moving the file and renaming is given below:
mv [options] [-T] source destination (for renaming a file)
mv [options] source [source2 …] destination (for moving a file)
9. locate: The locate utility works better and faster than it’s find counterpart because instead of searching the file system when a file search is initiated – Something find does – locate would look through a database. This database contains bits and parts of files and their corresponding paths on your system.
[code language=”bash”]locate index.html -n 20[/code]
10. cat: cat is one of the most frequently used commands. It has three related functions with regard to text files: displaying them, combining copies of them and creating new ones.
cat [options] [filenames] [-] [filenames]
cat file1 > file2
11. echo: The echo program displays text. It’s a handy way to create customized output in your terminal.
echo The value of variable x = $x
12. uname: The uname command within Linux allows you to view system information about your Linux environment. Here’s how to use uname effectively.
13. apt-get: Ubuntu is derived from Debian Linux. And Debian uses dpkg packaging system. A packaging system is a way to provide programs and applications for installation. APT (Advanced Package Tool) is the command line tool to interact with this packaging system.
apt-get is for installing, upgrading and cleaning packages
sudo apt-get update
14. chmod: This command is used to change the mode of a file or directories. It is used to change the permission granted by Linux to an executable file or directories. An example of the same is as follows:
chmod options permissions file name
Let’s say you are the owner of a file named myfile, and you want to set its permissions so that:
the user can read, write, ande xecute it;
members of your group can read ande xecute it; and
others may only read it.
This command will do the trick:
chmod u=rwx,g=rx,o=r myfile
Each digit is a combination of the numbers 4, 2, 1, and 0:
4 stands for “read”,
2 stands for “write”,
1 stands for “execute”, and
0 stands for “no permission.”
chmod 754 myfile
15. ping: Ping command is used to check the connection to the server. For example, if you do ping techdenovo.com, you get the following results. This command checks whether techdenovo.com gets connected and comes back. This command inspects the round-trip time and displays the results as follows. You can basically use this command to check your internet connectivity. If you ping a particular server (it can be any of the server google.com or yahoo,.com or anything), then it confirms that your internet connection is active.
Some basic tips for using Linux commands:
- Use Ctrl+C or Ctrl+Z to terminate any command safely. Firstly, use Ctrl+C and if it doesn’t stop with that then go for Ctrl+Z.
- You can use clear command to clear the terminal if it is filled up with commands.
- Use the exit command to exit from the terminal.