Useful Commands & Programs for Linux

File System

Remove directory and its contents – rm -rf directory_to_remove

Check disk space – df -h /directory_to_check

File Compression

Create a gzipped tarball in linux – tar -zcvpf new_tarball_name.tar.gz /var/www /home/username

z – use gzip for best compression
c – create a new archive called new_tarball_name.tar.gz
v – verbose (tar command will display progress)
p – keep the current file permissions
f – new_tarball_name.tar.gz (the location and name of the archive being created)

Decompress – tar -zxvf new_tarball_name.tar.gzZip & Unzip
zip -r new-zip-name /directory/to/zip
unzip zip-file-name

Install Ubuntu
apt-get install rsync
Install CentOS
yum install rsync
Generate a new key
ssh-keygen -t rsa -b 2048 -f /home/user/rsync-key
Concatenate the new key with an existing user's authorized keys file
cat rsync-key.pub >> /home/user/.ssh/authorized_keys

Add new user
adduser user_name
Add existing user to group
usermod -a -G group_name user_name
Create .ssh folder and authorized_keys file
mkdir .ssh
touch .ssh/authorized_keys
chown -R user_name:user_name .ssh
chmod 700 .ssh
chmod 600 .ssh/authorized_keys

For locking down to certain ip addresses.

Tags: