Linux command list


Fortunately, I have been involved in data analysis in my work since December. However, as I have more opportunities to use Linux commands, I have summarized them for review. I will refer to the course of dot installation. I can't believe this is free, but ...

Reference video


Use on CentOS, a local development environment

↓ How to set up the environment

Command list

pwd: Check current directory

[vagrant@localhost ~]$ pwd

clear, Ctrl + l: screen reset

cd: Move directory

cd [directory name]: move to [directory name]

[vagrant@localhost ~]$ pwd
[vagrant@localhost ~]$ cd unix_lessons/
[vagrant@localhost unix_lessons]$ pwd

cd ..: Move to the next higher directory

[vagrant@localhost unix_lessons]$ pwd
[vagrant@localhost unix_lessons]$ cd ..
[vagrant@localhost ~]$ pwd

cd-: Return to the previous directory

[vagrant@localhost unix_lessons]$ pwd
[vagrant@localhost unix_lessons]$ cd ..
[vagrant@localhost ~]$ pwd
[vagrant@localhost ~]$ cd -
[vagrant@localhost unix_lessons]$ pwd

cd! $: Move file by quoting the last string passed to the previous command

[vagrant@localhost unix_lessons]$ ls myapp/
[vagrant@localhost unix_lessons]$ cd !$
cd myapp/
[vagrant@localhost myapp]$

Successful move to myapp

ls: Check lower file

mkdir: create directory

[vagrant@localhost unix_lessons]$ mkdir myapp
[vagrant@localhost unix_lessons]$ ls

cp: Copy file

cp [File to copy] [Destination]

Copy myapp to myapp2 in the same directory

[vagrant@localhost unix_lessons]$ cp -r myapp myapp2
[vagrant@localhost unix_lessons]$ ls
myapp  myapp2
$ cp -r ./foo /home/hoge/aaa

If you want to keep the attributes of the copy source, also use the "-p" option.

$ cp -rp ./foo /home/hoge/aaa

mv: move files

mv [File to move] [Destination]

Move myapp3 files to the lower level of myapp2

[vagrant@localhost unix_lessons]$ ls
myapp  myapp2
[vagrant@localhost unix_lessons]$ mkdir -p myapp3/config
[vagrant@localhost unix_lessons]$ ls
myapp  myapp2  myapp3
[vagrant@localhost unix_lessons]$ ls myapp3
[vagrant@localhost unix_lessons]$ mv myapp3 myapp2
[vagrant@localhost unix_lessons]$ ls myapp2

rmdir: delete files

rmdir [filename you want to delete]

[vagrant@localhost unix_lessons]$ ls myapp3
[vagrant@localhost unix_lessons]$ rmdir myapp2/myapp3/config
[vagrant@localhost unix_lessons]$ ls myapp2/myapp3
[vagrant@localhost unix_lessons]$ rmdir myapp2
rmdir: failed to remove `myapp2':Directory is not empty
[vagrant@localhost unix_lessons]$ rm -r myapp2
[vagrant@localhost unix_lessons]$ ls

cat: Check the contents of the file

[vagrant@localhost unix_lessons]$ cat ./myapp/hello.txt

・ You can check the contents of the file image.png

less: Check the contents of the file

Usage is different from cat

・ Arrow: Scroll ・ Space / Ctrl + F One screen ahead ・ Ctrl + B one screen before ・ Move to the beginning of g ・ Shift + g Move to the end ・ Q end ・ / [Search term](n: next Shift + n: previous)

Ctrl + c: Cancel

Search the history of Ctrl + r commands

history: Display a list of past commands

If you want to execute the command in the list, you can execute it with![Arbitrary number].

You can quote various commands immediately before

[vagrant@localhost unix_lessons]$ !pw ← Execute the command starting with pw most recently
[vagrant@localhost unix_lessons]$ !pw:p ← Ayafuyara:Only display with p is possible
[vagrant@localhost unix_lessons]$ !!← Execution

help, man: command help display

[vagrant@localhost unix_lessons]$ mkdir --help
Usage: mkdir [OPTION]... DIRECTORY...
Create a directory. However, if the directory already exists, nothing is done.

Required arguments for long options are also required for short options.
  -m, --mode=MODE   set file mode (as in chmod), not a=rwx - umask
  -p, --parents     no error if existing, make parent directories as needed
  -v, --verbose     print a message for each created directory
  -Z, --context=CTX  set the SELinux security context of each created
                      directory to CTX
      When COREUTILS_CHILD_DEFAULT_ACLS environment variable is set, -p/--parents
      option respects default umask and ACLs, as it does in Red Hat Enterprise Linux 7 by default
            --help Show this usage and exit
      --version Display version information and exit

Report mkdir bugs to [email protected]
GNU coreutils home page: <>
General help using GNU software: <>
Report mkdir translation bugs to <>
For complete documentation, run: info coreutils 'mkdir invocation'


vi Start vim with [filename]

vim has a command mode and an edit mode. Edit mode if "INSERT" is displayed at the bottom left.

〇 Command mode ⇒ Edit mode: i 〇Edit mode ⇒ Command mode: Esc

To exit / save, use command mode : w Save : q end : q! Discard changes and exit

Environment startup

〇 Launch a virtual machine with Windows PowerShell

PS C:\Users\takuy> cd MyVagrant/MyCentOS
PS C:\Users\takuy\MyVagrant\MyCentOS> vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'bento/centos-6.8' version '2.3.4' is up to date...
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
PS C:\Users\takuy\MyVagrant\MyCentOS> vagrant status
Current machine states:

default                   running (virtualbox)

The VM is running. To stop this VM, you can run `vagrant halt` to
shut it down forcefully, or you can run `vagrant suspend` to simply
suspend the virtual machine. In either case, to restart it again,
simply run `vagrant up`.

〇 Load MyCentOS created with PuTTy Username and pass are vagrant

When to finish

〇Exit command on PuTTy

〇 Stop the virtual machine on Powershell

PS C:\Users\takuy\MyVagrant\MyCentOS> vagrant suspend
==> default: Saving VM state and suspending execution...


・ Http://

Recommended Posts

Linux command list
Linux command # 4
Linux command # 3
Linux command # 5
What is Linux? [Command list]
linux at command
[Linux] Search command
Linux command <Basic 2>
Linux [directory command]
Linux server command
Linux # Command Memo 1
Linux command [read]
Linux Command Summary
[Basic] linux command
Linux [shell command]
[Linux] Command / Knowledge
My linux command
Linux command <Basic 1>
Linux command collection
Linux mkdir command
Linux command basics
[Linux] Git command
Linux (command memory)
[Linux command summary] Command list [Must-see for beginners]
[Linux] Volume configuration command
Linux command cheat sheet
Linux command (sequential update)
Linux basic command memorandum
Linux command [File operation]
[Linux] Basic command summary
Linux command for self-collection
linux command error collection 1
Linux command line shortcut
[Linux command] cp command option list [Must-see for beginners]
[Linux command] ls command option list [Must-see for beginners]
[Linux command] touch 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] mv command option list [Must-see for beginners]
[Linux command] man command option list [Must-see for beginners]
[Linux command] ssh command option list [Must-see for beginners]
[Linux command] mkdir command option list [Must-see for beginners]
linux sar command CPU usage
[Linux] tar.gz compression / decompression command
pyenv pipenv Related command list
Easy df command on Linux
Linux tar xz command memo
Linux Command Dictionary (for myself)
linux: create original Terminal command
[Note] Useful linux command collection
Linux command memorandum [for beginners]
Linux PC spec check command
[Linux] User / group command summary
[Infrastructure] Linux command, shell script collection
[Linux convenient command] Try inserting exa
Command to create Linux Live USB
[Linux] OS recovery with restore command