Monday, August 27, 2018
Awesome Bash Command
Awesome Bash Command
Awesome Bash Commands
A curated list of awesome Bash useful commands. Inspired by awesome-shell and bash-handbook.
Table of Contents
- Files and directories
- Paths
- Devices
- Users and Groups
- Network
- Miscellaneous
- Other Awesome Lists
Files and directories
List files sorted by extension
$ ls -l -X
# Or
$ ls -l --sort=extension
Create a symbolic link for one directory or file
ln -s /var/www/html ~/www
ln -s ~/my/large/path/file.txt ~/myfile.txt
Create one empty file in current directory and subdirectories
find ./my/current/directory -type d -exec touch {}/.gitignore ;
Delete one specific file of current directory and subdirectories
find ./my/current/directory -name ".gitignore" -type f -delete
Copy file content to clipboard
Copy shell command output to cilpboard
$ cat myfile.txt | xclip -selection c
Copy entire directory to destination
$ cp -avr /my/current/directory /destination/directory
# Or
$ rsync -av /my/current/directory /destination/directory
Show the space usage of file or directory
Show the space usage of file or directory (recursive) in human readable format.
du -sh /var/log/dnf.librepo.log
# 4,1M /var/log/dnf.librepo.log
du -sh /var/log
# 2,2G /var/log
Delete all files in directory by pattern
find /usr/local/apache/logs/archive/ -name *2017.gz -delete
Move files by pattern
This command move all
*.js
files into *.ts
files (move equivalent)find src/ -type f -name "*.js" -exec bash -c mv {} `echo {} | sed -e "s/.js/.ts/g"` ;
Paths
Show the full path of (shell) commands
which bash
# /usr/bin/bash
which git node
# /usr/bin/git
# /usr/bin/node
Show the resolved path of symbolic link
realpath ~/www
# /usr/share/nginx/html
Determine the current directory
pwd
# /home/my/current/directory
Devices
Display file system disk space usage
Show the file system disk space usage in human readable format.
df -h
# Filesystem Size Used Avail Use% Mounted on
# devtmpfs 487M 0 487M 0% /dev
# tmpfs 497M 0 497M 0% /dev/shm
# tmpfs 497M 508K 496M 1% /run
# tmpfs 497M 0 497M 0% /sys/fs/cgroup
# /dev/vda1 30G 2.7G 26G 10% /
# tmpfs 100M 0 100M 0% /run/user/0
Mount a FAT32 USB device
$ mount -t vfat /dev/sdb1 /media/usb
link download
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment