Last active
September 6, 2024 01:29
-
-
Save rizkysyazuli/b9e538cf1286598383685ae4b06dd502 to your computer and use it in GitHub Desktop.
[Shell - File Management] Files management utilities #shell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
# Copy entire folder contents | |
cp -a dirA/. dirB/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment