/ Linux/MacOS Commands¶
Linuxize.com has some amazing guides for common Linux/MacOS commands and tasks.
If their site does not have cover the desired content, man <command>
to view the full documentation of a command.
Linuxize Basic Linux Commands¶
- Covers man, pwd, cd, ls, cat, touch, mkdir, ln, rm, cp, mv, apt, dnf, chmod, chown, sudo, useradd, passwd, userdel, groupadd, groupdel, and usermod
alias¶
Aliases are custom commands that map to a longer command.
Command | Description |
---|---|
alias <alias>="<command>" |
Create an alias |
which <alias/command> |
Locate an alias/command |
alias |
View the mappings of all aliases |
My shell aliases can be found in aliases.zsh
.
Resources:
du¶
Estimates disk usage of the given files or directories.
Command | Description |
---|---|
du -ha <file/directory> |
Get size of each file within the directory recursively |
du -h --max-depth=1 <directory> |
Get size of directories up to the first level |
du -hs |
Get only the size of the current working directory |
Resources:
find¶
Recursively searches for files and directories.
Command | Description |
---|---|
find -type f -iname <filename> |
Search for files by name, ignoring case |
find -type f -name '*.<file_extension>' |
Search for files by extension |
Resources:
less¶
Read contents of a file or command output quickly and without filling up terminal.
Command | Description |
---|---|
less <filename> |
Read the contents of a file |
| <command> | less
| Read the standard output (what would be printed to the terminal) of <command>
|
Commands inside less
Command | Description |
---|---|
h |
Display help |
q |
Exit |
g |
Go to first line of file |
#g |
Go to line # |
G |
Go to last line of file |
j /k |
Move forward and backward by line |
f /b |
Move forward and backward by window |
-N |
Toggle line numbers |
-S |
Toggle chopping long lines |
/<string> |
Search for <string> |
n /N |
Navigate between search matches |
Resources:
screen¶
I use screen to perform long-running tasks on a remote machine. It enables me to connect and disconnect from the machine (i.e. via SSH) without exiting the command.
Command | Description |
---|---|
screen -S <session_name> |
Start a named screen session |
screen -d |
Detach from current screen |
Ctrl+Alt then D | Detach from current screen when a command is running |
screen -ls |
List running screens and their session IDs |
screen -r <session_id> |
Reattach to screen |
screen -d -r <session_id> |
Reattach to screen from inside another screen |
exit |
Terminate current screen |
screen
in WSL
Error Message
To Fix
- Create an alternate screen directory with the appropriate permissions
- Point the
SCREENDIR
environment variable to that directory
Resources:
Additional Guides¶
- Linuxize shebang guide - run script without having to specify the interpreter
- Linuxize add to the PATH environment variable