Learn basic commands of Linux
Learn basic commands of Linux
Learn basic commands of Linux, a free and open-source operating system that you can make changes to and redistribute.
What Is Linux?
Linux is an operating system’s kernel. You might have heard of UNIX. Well, Linux is a UNIX clone. But it was actually created by Linus Torvalds from Scratch the Linux kernel and distributed its first version, 0.01, in 1991. Linux is free and open-source, that means that you can simply change anything in Linux and redistribute it in your own name! There are several Linux Distributions, commonly called “distros”.
- Ubuntu Linux
- Red Hat Enterprise Linux
- Linux Mint
- Debian
- Fedora
Linux is Mainly used in servers. About 90% of the internet is powered by Linux servers. This is because Linux is fast, secure, and free (open source). The main problem of using Windows servers are their cost. The OS that runs in about 80% of the smartphones in the world, Android, is also made from the Linux kernel. Most of the viruses in the world run on Windows, but not on Linux!
Linux features
- Open source
- Secure
- Simplified updates for all installed software
- Light weight
- Multiuser – multi task
- Multiple distribution like: Red Hat, Debian, Fedora etc.
Linux Shell or “Terminal”
A shell is a program that receives commands from the user and gives it to the Operating system to process, and it shows the output. Linux’s shell is its main part. Its distros come in GUI (graphical user interface), but Linux has a CLI (command line interface). In this article, we are going to cover the basic commands that we use in the shell of Linux.
- To open the terminal, press Ctrl+Alt+T in Ubuntu or Kali
Basic Commands of Linux
-
Command_name –help
Most commands have a –help
option, which prints a short message about how to use the command and other mandatory arguments. Like: ls –help
-
The man command
Almost all Linux commands are distributed together with man pages. A man or manual page is a form of documentation that explains what the command does, examples of how you run the command, and what arguments it accepts. The man command is used to display the manual page of a given command. Example man ls
To navigate the man pages, use the Arrow, Page Up, and Page Down keys or scroll the mouse . You can also press the Enter key to move one line at a time, the Space bar to move to the next screen, and the b key to go one screen back. To exit the man page, press the q key.
Current Working Directory pwd command
-
pwd
:
This command displays the path of your current working directory.
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/username"
.
-
Listing Contents of Directory
ls command
The ls
command lists information about files and directories of the current working directory. It displays a list in alphabetical order of the names of all files in the current directory. You can list files in a specific directory, pass the path to the directory as an argument. Like: ls /usr
- Use
ls --help
command will list all commands related to ls command. - Use
ls -a
command to display all files including hidden files. - Use
ls -R
command will list all the files in the sub-directories as well - Use
ls -al
command will list the files and directories with detailed information like the permissions, size, owner, etc.
Working with directory
5. Changing directory cd command
cd
command: Use the cd command to go to a directory. For example, if you are in the home directory, and you want to go to the downloads directory, then use cd Downloads. Remember, this command is case sensitive, and you have to type in the name of the folder exactly as it is. But there is a problem with these commands. Imagine you have a folder named “yam guru”
. In this case, use cd 'yam guru'
.
cd
go to the home directorycd Downloads
go to the Downloads directorycd Downloads/Music
“absolute path” to go to the specific directoryd ..
back to home directory
6. Creating a directory mkdir command
Use the mkdir
command to create a directory. For example, if you want to make a directory called files, then use mkdir files
. Remember, as told before, if you want to create a directory named "my files”
, then use mkdir 'my files'
. You can create multiple directories at once. Use mkdir apple ball cat
.
mkdir files
to create normal directorymkdir .kitcat
to create hidden directory
7. Rename a directory mv command
Use the mv
command to rename and move a directory. For example, if you want to rename a directory called apple to fruit, then use mv apple fruit
it will be renamed to fruit. If you want to move directory one path to another then use mv files myfiles
.
mv apple fruit
rename apple directory to fruitmv files myfiles move
files inside myfiles
8. Delete a directory rmdir
command
Use rmdir directory_name
to delete a directory. Remember rmdir
can only be used to delete an empty directory. For example you want to delete a directory called cat, then use rmdir cat
. To delete a directory containing files and other directory, use rm -r directory_name
.
My God to good Information
Thankyou For the Information
Keep it up