Most people consider Linux to be a complicated operating system used by programmers. But it’s not as complicated as it seems. Linux is a family of open-source Unix-like operating systems, that means that you can simply change anything in Linux and redistribute it in your own way. There are several Linux Distributions, for example Ubuntu, Fedora, Linux Mint, Redhat etc.
Linux is fast, secure and free. Linux is also used in servers. Linux servers power about 80% of the internet.
Terminal or Linux Shell
When operating a Linux OS, you need to use a shell — an interface that gives you access to the operating system’s services. Shell is a program which receives the commands from the user and gives it to the Operating System and it gives the output. In this blog, we are going to cover a few basic commands that we use in the shell of Linux.
Open terminal
To open the terminal in Ubuntu press Ctrl+Alt+T , or press Alt+F2, In Raspberry Pi type in lxterminal . There is also another way of taking it called GUI
Linux Basic Commands
Commands | Description |
mkdir & rmdir | mkdir command is used to create a folder or a directory. For example, if you want to make a directory/Folder called ABC, then you can type mkdir ABC. rmdir command is used to delete a directory and it can only be used to delete an empty directory/Folder. To delete a directory/Folder containing files, then use rm. |
pwd | This command is used to find the directory in which you are in. When you first open the terminal, you are in the home directory of the user. To get which directory you are in, you can use the “pwd” command. It will show us the absolute path, which means the path which starts from the root. The user directory is usually something like /home/username The root is the base of the Linux file system and is denoted by a forward slash( / ). |
ls | This command is used to know what files are in the directory you are in. And also you can see the hidden files by using the command ls -a. |
rm | This command is used to delete files. rm -r command will delete all files within a specific directory/Folder. |
touch | This command is used to create an empty file, For example touch abc.txt. |
cp | This command is used to copy the files. |
mv | This command is used to move files .You can also use the mv command to rename a file. For Example if you want to rename the file abc to xyz, we can use mv abc xyz. mv command will take the two arguments. |
locate | This command is used to locate a file in a Linux system, For Example locate abc.txt. The locate command works fast because it runs a background process to find the location of files in your system. Run sudo updatedb command to update that local cache, |
sudo | sudo stands for SuperUser Do. So, if you want to run any command with root or administrative privileges, you can use the sudo command. For example, if you want to change or set the new password of a device you can use the command sudo passwd ,Then type in the new root password. Only the user who has entry in /etc/sudoers file those users can run sudo command |
df | This command is used to find out the available disk space in each of the partitions in your system. Type df in the command line and you can see the used/available space in % and in KBs. If you want it in megabytes, you can use the command df -m. |
du | This command is used to find out the disk usage for a particular folder or file in Linux. For example, if you want to find the disk space used by the downloads folder in Linux, you can use the command du Downloads. |
uname | This command is used to show the information about the system where your Linux distro is running. And also you can use the command uname -a to get the information of kernel release date, version, processor type, etc. |
apt-get | apt command is used to work with packages in the Linux command line. To install packages use apt-get. This requires root privileges, for that use the sudo command with it. For example, if you want to install the vlc , type in the command sudo apt-get install vlc. Similarly, any packages can be installed like this and you can update your repository each time you try to install a new package. You can do that by using the sudo apt-get update command . We can also upgrade the distro by using sudo apt-get upgrade. To search the package you can use a command apt-cache search. For Example you can type apt-cache search vlc . |
hostname | This command is used to display the hostname of the device and to check IP address you can use hostname -I which gives you the IP address in your network. |
Conclusion
The title of this chapter is “Learn Linux Basic Commands Quickly,” and that is what we covered. The choice of which one to use in a situation is up to you. It’s still a good idea to know the various similarities, Linux is all about variety and choice, even in such seemingly small matters as commands run in the shell.