Linux command memorandum [for beginners]

Frequently used Linux commands

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.

File and directory operations related

cd [PATH]

** 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,  cd .. You can go back by doing. If you enter only cd, it will move to your home directory.

pwd

** Meaning of [Print Working Directory] **. Print = Display / Output. Show the absolute path of the directory you are currently working on.

ls [PATH]

** 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.

File content display, movement related

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 cat, but 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,

  1. Rename file / directory
  2. Move the file / directory to the specified destination File name change is described in the order of ** original file name to be changed **, such as 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 mv. cp hoge hoge2 creates hoge2 with a duplicate of the contents of hoge. Hoge is not deleted. With 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.

File / directory creation / deletion related

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.

Administrator privileges, installation related

sudo apt-get install [Package name] ...

Package installation command.

sudo 

** 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. The above 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  sudo su Move to root privileges by doing. ʻExit` when exiting

Other commands, input related

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

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.

man [command]

** [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, q You can see not only commands but also system directories and system call related manuals.

TAB key

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
  2. Show directory suggestions

** 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 and ʻapt-add-repository. 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 command ** 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.

Finally

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.

Recommended Posts

Linux command memorandum [for beginners]
[Linux command summary] Command list [Must-see for beginners]
Linux basic command memorandum
Linux operation for beginners Basic command summary
Linux command for self-collection
[Linux command] cp command option list [Must-see for beginners]
[Linux command] ls command option list [Must-see for beginners]
[Linux command] less command option list [Must-see for beginners]
[Linux command] cat command option list [Must-see for beginners]
[Linux command] pwd command option list [Must-see for beginners]
[Linux command] rm command option list [Must-see for beginners]
[Linux command] cd command option list [Must-see for beginners]
[Linux command] man command option list [Must-see for beginners]
[Linux command] mkdir command option list [Must-see for beginners]
Linux distribution recommended for beginners
Linux Command Dictionary (for myself)
Convenient Linux shortcuts (for beginners)
linux memorandum
Linux command # 4
Command memorandum
Linux command # 5
Command memorandum
Frequently used Linux commands (for beginners)
[Must-see for beginners] Basics of Linux
Linux command list
linux at command
[Linux] Search command
Roadmap for beginners
Linux memorandum [links]
Linux [directory command]
Linux server command
Linux Command Summary
[Basic] linux command
Linux [shell command]
My linux command
Memorandum conda command
Linux command <Basic 1>
setuptools command memorandum
Linux command collection
Linux mkdir command
Linux command basics
[Linux] Git command
Linux (command memory)
[Linux command] A memorandum of frequently used commands
[For recording] Pandas memorandum
Spacemacs settings (for beginners)
[Linux] Volume configuration command
Linux command cheat sheet
memorandum of vi command
Linux command (sequential update)
[For memo] Linux Part 2
AtCoder Beginners Selection memorandum
[Linux] Basic command summary
What is Linux for?
Linux command line shortcut
Dijkstra algorithm for beginners
manjaro linux configuration memorandum
OpenCV for Python beginners
Freecad memorandum (for myself)
[For beginners] How to use say command in python!
[Linux] Basics of authority setting by chmod for beginners