[linux] Command notes that you often forget
environment
zsh
Pipe command
alias -g A='| awk'
alias -g C='| pbcopy'
alias -g G='| grep --color=auto'
alias -g H='| head'
alias -g S='| sort'
alias -g T='| tail'
alias -g L='| less -iMR'
alias -g X='| xargs'
Check file size
install ncdu
apt install ncdu
This is the fastest, easiest and most convenient
df, du command is too lazy
Whole system
df
Current directory (1st level)
du -sh ${pwd}
Current directory (all levels)
du -Sh ${pwd}
Lowercase s: 1st level
Uppercase S: All levels
-h: By size
alias setting
alias size='echo 'List of sizes for all levels' && du -Sh ${pwd}* | sort -h'
alias size1='echo '1 layer size list' && du -sh ${pwd}* | sort -h'
Add user to group
sudo adduser username groupname
User information
who
whoami
${whoami}
Same as -a, --all -b -d --login -p -r -t -T -u
-b, --boot The last time the system booted
-d, --dead Show terminated processes
-H, --heading Show header lines
--ips print ips instead of hostnames. with --lookup,
canonicalizes based on stored IP, if available,
rather than stored hostname
-l, --login Show system login process
--lookup Attempt to get the official host name from DNS
-m Show only host name and user associated with standard input
-p, --process Shows active processes started by init
-q, --count Login name and number of logged-in users
-r, --runlevel Show current runlevel
-s, --short Show only name, line and time (standard)
-t, --time Shows the time when the system time was last changed
-T, -w, --mesg Add user message status with +,-or?
-u, --users List logged in users
Version confirmation
cat /etc/os-release
Authority
- If you add the -R option, everything under the directory will change *
chmod: (change mode)
Change file and directory permissions
chmod 755 data
chmod -R 755 data
r |
4 |
Read permission |
w |
2 |
Write permission |
x |
1 |
Execution authority |
chown: (change owner)
Change the owner of a file or directory
chown username data
chown -R username data
chgrp: (change group)
Change groups of files and directories
chgrp usergroup data
chgrp -R usergroup data
font
fc-cache -Ev
fc-cache -fv
-E, --error-on-no-fonts raise an error if no fonts in a directory
-f, --force scan directories with apparently valid caches
-r, --really-force erase all existing caches, then rescan
-s, --system-only scan system-wide directories only
-y, --sysroot=SYSROOT prepend SYSROOT to all paths for scanning
-v, --verbose display status information while busy
-V, --version display font config version and exit
-h, --help display this help and exit