Skip to content

Instantly share code, notes, and snippets.

@rizkysyazuli
Last active November 22, 2022 16:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rizkysyazuli/b9e538cf1286598383685ae4b06dd502 to your computer and use it in GitHub Desktop.
Save rizkysyazuli/b9e538cf1286598383685ae4b06dd502 to your computer and use it in GitHub Desktop.
[Shell - File Management] Files management utilities #shell
# a typical rsync file transfer upload command
# https://explainshell.com/explain?cmd=rsync+-uavl+--exclude-from%3D%27exclude-list%27+--delete+.%2F+%24USER%40%24HOST%3A%24UPLOAD_PATH
rsync -uavl --exclude-from='exclude-list.txt' --delete ./ user@host:/upload/path
# rsync copy folders
rsync -avzh --exclude=dir/ /source /destination/
# rsync download remote directory
rsync -avzh user@host:/target/path ./destination
# mount a remote folder to local filesystem
# https://askubuntu.com/a/987775/343568
sshfs user@host:/remote/path /local/path
# to unmount
sudo umount /local/path
# Search for files
# https://www.cyberciti.biz/faq/linux-unix-how-to-find-and-remove-files/
find ./dir -name "string"
# Check directory size
du -sh directory_name
# Check volume size
df -h
# Create symlinks. add -f to force update
ln -s /path/to/file file
ln -sn /path/to/folder folder
# Create tar.gz
tar -cvzf archive.tar.gz ./folder_name
tar -cvzf archive.tar.gz file1 file2 ...
# Extract archive
tar -xvzf archive.tar.gz
# Set permission: 755 to dirs, 644 to files
chmod -R u+rwX,go+rX,go-w ./path/
# Create a group of files with a common prefix
touch store-{products,cart,coupons,utils}.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment