Display details about commands
List contents of a directory
1
| alias ls="ls --color=auto"
|
Path
Go to home directory
Move a level up
Return to the previous directory
Go to a specific directory
Create
Create a new directory
1
| mkdir /path/to/newdirectory/
|
Create a new subdirectory
1
| mkdir -p /path/to/newdirectory/subdirectory
|
Copy
Copy a file
1
| cp /path/to/file.xxx /path/to/destination/newfile.xxx
|
Copy a directory
1
| cp -r /path/to/directory/ /path/to/newdirectory/
|
In Linux, folders end with a slash /
and files do not.
Move
Move a file to a new folder
1
| mv /path/to/file.xxx /path/to/newdirectory/
|
Move a file to a new folder and rename it
1
| mv /path/to/file.xxx /path/to/destination/newfile.xxx
|
Move a file to current directory
1
| mv /path/to/file.xxx ./
|
Remove
Remove a file
Remove an empty directory
1
| rm -r /path/to/directory
|
Remove a directory and its contents
1
| rm -rf /path/to/directory
|
Permissions
Change permissions for owner (u), group (g), and others (o), respectively, and (a) for all. You can call the above letters with operator (+, -, =) and permissions (r, w, x), which stand for read, write, and execute, respectively.
1
| chmod ugo+r, o-wx /path/to/file.xxx
|
You can also use 3 numbers to set permissions. Each number is a sum of the following:
- 4 for read permission
- 2 for write permission
- 1 for execute permission
The first number is for the owner, the second for the group, and the third for others.
1
| chmod 744 /path/to/file.xxx
|
Execute
Execute a file
Multiple Shell Sessions
screen
Create a new session with a name
List all sessions
Attach to a session
Detach from a session
tmux
Create a new session
Create a new session with a name
1
| tmux new -s session_name
|
List all sessions
Attach to a session
Detach from a session
Kill a session
1
| tmux kill-session -t session_name
|
Rename a session
1
| tmux rename-session -t old_session_name new_session_name
|