Linux terminal commands

Published in Linux on Nov 9, 2022

Symbolic Link

ln -s source.txt softlink.txt

Copy files from a local computer to a remote computer

scp somefile [email protected]:/home/username/

Copy files from a remote server to your local computer

scp [email protected]:/home/file_name /local-username/file-name

Compress a folder

tar -czvf prog-1-jan-2005.tar.gz /home/jerry/prog /this.sql

Uncompress a folder

tar -zxvf prog-1-jan-2005.tar.gz

Recursive zip

zip -r mydir

Concatenate (join) files togther

cat *.csv >> output.csv

Upload a file to remote server

curl -k -u web123 -T filename ftps://

MySQL Dump & Restore

mysqldump -u something -p --host=[hostname] dbname > db_backup.sql
mysql -u root -p dbname < db_backup.sql

MySQL Dump & restore with compression

mysqldump -u something -p dbname | gzip -9 > db_backup.sql.gz
gunzip < backup.sql.gz | mysql -u username -p dbname

Recursively remove all folders starting with _

rm -rf `find . -type d -name '_*'`

Download a whole website

wget --recursive --no-clobber --page-requisites --convert-links --restrict-file-names=windows --no-parent -H --domains

Recursive change of owner

sudo chown -R user:group dir/

Disk size/availability


Recursive count of files in a directory

find -type f | wc -l