Frequently used Linux commands

It is a memorandum of a little operation when operating a Linux server I will update it every time to add more

cd command [move]

Command to move to the specified path

[vagrant@vagrant ~]$ cd /var/www
[vagrant@vagrant www]$

pwd command [Know your current location]

Command to check the current location

[vagrant@vagrant ~]$ pwd
/home/vagrant

cp command [duplicate]

Copy command. Commands for duplicating files, folders, etc.

cp copy source file copy destination file

cp fileA.txt fileA_copy.txt




 Frequently used options

 |option|Contents|
 |:---------------|:------------------|
 | -a |Preserve and copy the attributes of the original file and the directory structure. As far as possible.|
 | -r |Copy the entire directory (recursive)|


 > Copy the entire folder
```cp -r Copy source directory Copy destination directory```

 Other options Reference URL
https://eng-entrance.com/linux_command_cp




## mv command [move / rename]
 Move or rename files etc.

##### File name change
 > mv Target file File name you want to change
```mv file1 file2```

 Use when you want to change the file name to the file name you want to change
 * Also, it works even if you change the folder name.

##### Move
 > mv file 1 file 2 file 3 directory A

#### **`mv file1 file2 file3 ./dir`**

Move the file to the target folder

rsync command [Synchronize]

Command to "sync" files and directories with remote environment

rsync-[options] sync source / sync destination /

Frequently used options

option Contents
-a Archive mode
-v Display the operation details
-z Compress the data in transit

Permission-related options

option Contents
-e Hold executable attributes
-p Hold permissions
-g Keep the owning group as is
-o Keep the owner as is (root authority is required to keep the owner other than yourself)

Symbolic link related options

option Contents
-l Copy the symbolic link as it is

Click here for other details https://www.atmarkit.co.jp/ait/articles/1702/02/news031.html

Example of using ssh to sync to your own PC
rsync -avz -e 'ssh -i ~/Documents/login/[Key name].pem'  --rsync-path='sudo rsync'  [ssh user]@[domain]:/var/www/html/[Server target directory] ./[Local target directory name]

df command [Display free disk space]

You can see the free space on the disk

Frequently used options

option Contents
-h Display in easy-to-read units according to size
--total Show total free space

du command

Show disk usage

du [Options] [File or Directory]

Frequently used options

option Contents
-s Show only totals for specified directories(Do not include subdirectories)
-d depth Specify the depth of the directory to be aggregated
-h Displayed in easy-to-read units according to size
Capacity display only for folders directly under the directory

du -sh ./* | sort -nr

Recommended Posts

Frequently used Linux commands
Frequently used linux commands
Linux Frequently Used Commands [Personal Memo]
[Linux] Frequently used Linux commands (file operation)
Frequently used Linux commands (for beginners)
List of frequently used Linux commands
[Linux] Frequently used Linux commands (folder operation)
pyenv Frequently used commands
Frequently used tmux commands
Frequently used pip commands
[Linux] Review of frequently used basic commands 2
[Linux] Review of frequently used basic commands
Linux commands
linux commands
Frequently used commands in virtualenv
[Linux command] A memorandum of frequently used commands
Linux commands
Linux commands
8 Frequently Used Commands in Python Django
[Anaconda3] Summary of frequently used commands
Network Linux commands
Verbalize Linux commands
Linux user commands
New Linux commands! !!
Basic LINUX commands
Various Linux commands
Typical Linux commands (7)
Summary of frequently used commands of django (beginner)
Summary of frequently used commands in matplotlib
[Linux] List of Linux commands used in practice
[Python/Django] Summary of frequently used commands (3) <Operation of PostgreSQL>
[Python/Django] Summary of frequently used commands (4) -Part 2- <Production operation: Amazon EC2 (Amazon Linux 2)>
[Linux] Group related commands
Linux commands to remember
[Python/Django] Summary of frequently used commands (4) -Part 1- <Production operation: Amazon EC2 (Amazon Linux 2)>
New Linux commands! !! Part 2
[Python/Django] Summary of frequently used commands (2) <Installing packages>
Summary of frequently used commands (with petit commentary)
A collection of commands frequently used in server management
Display a list of frequently used commands on Zsh
[For beginners] Django Frequently used commands and reference collection
Studying Linux commands and frustration
[Python] Frequently used library code
Frequently used subpackages of SciPy
Python frequently used code snippets
Basic knowledge of Linux and basic commands
[Golang] Notes on frequently used functions
Handle dates in Linux bash commands
Classify frequently used file / folder dialogs
[Linux Mint 20] Various WiFi confirmation commands
Convenient shortcut keys for Linux commands! !! !!
Linux
Linux commands that you often forget
[Linux] File and directory operation commands
Commands often used on GAE / P
Try compiling Linux commands (cross-compilation practice)
Linux commands related to character code
About Linux commands Super basic edition
Note: Linux concepts and minimum commands
Use Linux commands on Android devices
I tried to summarize the Linux commands used by beginner engineers today-Part 1-