Do you see various Linux commands in some setup documents but don't know exactly what they do?
Want to specialize in Linux commands? Or are you just a curious Linux user? Then I advise you to read this article carefully!
command line interface (CLI – Command Line Interface)It is generally not preferred by beginners or home users. On the other hand, the command line interface is much more powerful, functional and faster than the graphical interface. I am a person who thinks that this topic is among the first things that a Linux user should learn. For this reason, I have prepared this article for you, which I think contains the basic points that should be known for the use of the command line interface on Linux systems.
The first thing to consider before learning basic Linux commands should be the sequence of Linux commands. Thus, Linux commands can be understood more easily.
Lineup of Linux commands
Linux commands generally use the following syntax.
<-option(s)> <parameter (if any)>
Options are generally defined as single letters, but can also be found in long versions. When typing options in Linux commands -
(hyphen) is used. If it is written in long form --
(two dashes) is used.
Let's continue with the examples.
--help
To get information about a command --help
option is used. Let's take a quick look at examples:
ls --help
When you type the command, on the screen ls
You will see output listing the parameters the command can take and briefly explaining them. Here ls
command, --help
is an option.
cd /
working directory when you type the command /
(root) directory. Here cd
command, /
is the parameter.
You do not have to use options and parameters in all commands at the same time. Some commands can run without entering options and parameters. You will see examples in the “Basic Commands” section.
We basically talked about the Linux command structure, now let's move on to the basic commands.
Basic Linux commands
work - list directory
Used to list directories and files. During listing, directories and files are represented by various colors.
ls
Lists files and directories in the current directory.
ls -a
It lists hidden directories and files as well.
Ls -l
It lists the directories and files in detail. ls -lh
You can print it in a more readable format.
work
Lists the given directory.
It also has options such as sorting files by name and size. For more detailed information man ls
You can enter the command, learn the use of the command and all its parameters.
cd - changing ddirection
It is used to switch between directories.
cd /
Goes to root directory.
cd
Only if the command is typed will the user go to their home directory.
Cd ..
Goes to one parent directory.
The command parameter is from the root directory, i.e. /
If it starts with a sign, this is called full path usage.
cd / home
/home
goes to directory. /home
directory is a directory under the root directory.
A usage like the one below is called relative path usage. It still references the root directory.
cd ../ ..
cp – copy
It is used to copy files.
cp
To copy a directory and its contents -r
You must use the parameter.
cp -r
To copy more than one file and/or directory, you can write the files and directories to be copied in the source part in order.
cp -r
mv – move
Used to move files or directories. Another function is to rename files or directories.
mv mv
To get information about the result of the operation -v
You can use parameter.
rm – remove
Used to delete files. Normally rm
, does not delete the directory. For this -r
(--recursive
You must use the ) parameter. If you want it to not ask questions while deleting, delete what is there -f
(--force
You must use the ) parameter. The use of these two parameters together is quite dangerous. You should be careful while using it.
rm rm -rf
mkdir – make dirsector
Used to create a new directory.
mkdir
To create multiple directories at once, simply leave a space between directory names.
mkdir
If you want to create nested directories, -p
You can use parameter.
mkdir -p
To print the operation result -v
You can use parameter.
mkdir -pv
rm is – remove dirsector
It serves to delete empty directories.
is rm
pwd – pprint work ddirection
Returns the current directory path as a full path from the root directory.
pwd
where's
Indicates where or where a file is located.
whereis
whats
It is used to get brief information about commands.
whatis
Mon
It is used to get detailed information about commands. For more information about man files here You can look at.
Man
clear
It is one of the most frequently used commands. It serves to clean up the command line interface.
The last command of this post clear
Now that you have learned the command, you can open a clean page in the command line interface, apply what you have learned and use the Linux command line interface. explore You can exit.