It is a memorandum of a little operation when operating a Linux server I will update it every time to add more
Command to move to the specified path
[vagrant@vagrant ~]$ cd /var/www
[vagrant@vagrant www]$
Command to check the current location
[vagrant@vagrant ~]$ pwd
/home/vagrant
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
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
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]
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 |
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 |
du -sh ./* | sort -nr
Recommended Posts