In Linux, we basically use CUI (Character User Interface) to do various tasks. Of course, there are many distributions that provide desktop environments, Most of the work is done with CUI in virtual environments such as server construction, various Config settings, Docker, GCP, and AWS.
Therefore, I will introduce the basic commands, and also introduce the options that are often used for each command. On the contrary, I will not introduce complicated usage using pipes. At the same time, I will introduce the original English, so please remember not only the list of letters but also the meaning.
** Meaning of [Change Directory] **. File = directory in linux.
Specify any directory after
cd and move.
Both absolute and relative paths can be used.
If you want to move to the previous directory,
You can go back by doing.
If you enter only
cd, it will move to your home directory.
** Meaning of [Print Working Directory] **. Print = Display / Output.
Show the absolute path of the directory you are currently working on.
** Meaning of [List Segments] **. Display a list of files and folders in the specified directory. The latter half of the path can be omitted. In that case, the list in the current directory is displayed.
cat [File name] ...
** [Catenate] ** means. Catenate = concatenation.
Display the contents of the specified file on the command line.
If you specify multiple files, the contents of each file are concatenated and displayed on the command line.
less [File name]
Display the specified file contents on the command line.
It's very similar to
less is recommended for viewing long files.
To end browsing, press the
q key. (Quit: Exit)
mv [Source] [Destination]
** [Move] ** means. There are two main uses,
mv hoge hoge2. Directory is also possible. To move to the specified destination, describe in the order of ** original file move destination directory **, such as
mv hoge workspace /.
cp [Source] [Destination]
** [Copy] ** means.
The description method is the same as
cp hoge hoge2 creates hoge2 with a duplicate of the contents of hoge. Hoge is not deleted.
cp hoge workspace /, the file name remains the same and is copied into the specified directory.
Also note that if a file called hoge2 exists at the time of
cp hoge hoge2, it will be overwritten.
touch [File name]
Create an empty file. There is also a function to change the time stamp.
mkdir [Directory name]
** [Make Directory] ** means.
Create an arbitrary directory. You can also create it by specifying the path.
rmdir [Directory name]
** [Remove Directory] ** means. Remove = Remove.
Delete the specified directory. However, if the specified directory is not empty, it cannot be deleted.
rm [File name]
** [Remove] ** means. Delete the specified file. The directory cannot be deleted, but it can be done with the following options.
sudo apt-get install [Package name] ...
Package installation command.
** Meaning of [Substitute (Super or Switch) User Do] **. There is a theory.
If you want to execute a command with other administrator privileges, enter this command at the beginning before using it.
sudo apt-get install is also an example.
By the way, if you want to make many settings in the config file that requires administrator privileges,
In some cases it is better to have root privileges in advance. In that case
Move to root privileges by doing. ʻExit` when exiting
The commands up to the above are basic operations, but from here you can use commands that are convenient for working with the CUI.
I will introduce the operation method that will help you to input.
Clear the command line display.
Resetting the command line makes it easier to work as you continue to work or start another work.
Also, with the standard settings, you can get the same effect with
Ctrl + L. L can be lowercase.
** [Manual] ** means.
You can find out how to use it, the types of options, etc. Official reference.
By default, it is displayed using the
less command, so when you exit,
You can see not only commands but also system directories and system call related manuals.
Although not a command, the
TAB key is a very important key in the CUI.
If you can master the TAB key, the work efficiency with CUI will increase dramatically, so it is recommended to always use it.
The main effects of the TAB key are as follows.
** 1. Display command candidates ** is effective when you forget a command or save the trouble of inputting.
For long commands like ʻapt-get install
, don't type everything ** ʻapt-g + TAB key + ʻi
+ TAB key ** By inputting halfway and pressing the TAB key, all the corresponding commands will be input. In addition to ʻapt-get, there are many types of apt such as ʻapt-config
In that case,
** ʻapt` + TAB key x 2 times **
By pressing the TAB key twice in a row like this, a list of command candidates corresponding to apt will be displayed.
Of course, not only apt but all commands can be used.
** 2. Display directory candidates ** is very similar to the corresponding command candidate list in the above example.
For example, when you enter the
cd + TAB key x 2 times **
By doing like, all the directories in the current directory will be displayed.
You can also display the directories in the hoge directory by pressing the TAB key twice at the
cd hoge / stage.
These are the main functions. The TAB key is very convenient, so please try it out.
Since it is a memorandum for beginners, only a part is explained depending on the command, Everything starts from the basics. First, let's master these.