Here are some examples that I’ve tested on Ubuntu

CRONTAB

Edit existing crontab file, or make new one:

crontab -e

List of cronjobs , display crontab file contents:

crontab -l

Removes the crontab file:

crontab -r
@reboot perl /usr/local/bin/dnsexit/ipUpdate.pl
0 11 * * * rsync -rav --delete /source.dir/ /target.dir
*****command
min (0-59)hour (0-23)day of the month (1-31)month (1-12)day of the week (0-6)
Sunday = 0
time format in crontab

FSTAB

Edit fstab:

nano /etc/fstab
Mount disk: UUID=xxxxxxxxxxxxxxxxxxxxxxxxxxxx /mounting_dir ext4 defaults 0 0
Mount nfs share: ser.ver.ip.address:/server_dir /local_mounting_dir nfs defaults 0 0
Mount samba share: //ser.ver.ip.address/share_name /local_mounting_dir cifs username=user,password=password 0 0

“Reloads” fstab for changes to take effect:

mount -a 

Different partitions types ext4 -> ext2, ext3, reiserfs, xfs, jfs, smbfs, iso9660, vfat, ntfs, swap, auto

share_name NOT dir_name!


LIST DISKS & UUID

Lists all block devices, UUID and partition:

lsblk -f


Lists block devices, UUID and attributes (issues with unpartitioned):

blkid

OWNER & PERMISSIONS

Changes the owner of all sub-directories and files in target dir:

chown -R nobody:nogroup /target_dir

Changes permissions of all sub-directories and files in target_dir:

chmod -R 777 /target_dir    

FILES & FOLDERS

List folders and their sizes:

du -sh *

Deletes directory and all files in it without prompting:

rm -rf

UPDATE

Full update without questions:

apt-get update -y && apt-get upgrade -y && apt-get dist-upgrade -y

Removes packages that are no longer needed:

apt-get autoremove

SAMBA

Edit samba configuration:

nano /etc/samba/smb.conf    

Share example:

[share_name]
guest ok = yes
path =
local_shared_dir
available = yes
read only = no
browseable = yes
public = yes
writable = yes
create mask = 0777

Restart samba:

systemctl restart smbd    

(stop, start)


NFS

SERVER:

Edit server NFS configuration:

nano /etc/exports

Share example:

/local_shared_dir 192.168.xx.0/24(ro,sync,no_subtree_check)

Export “NFS table” (this is necessary after NFS edit) :

exportfs -a     

Restarts NFS to apply changes:

systemctl restart nfs-kernel-server

CLIENT:

Share mounting examples:

terminal:

mount ser.ver.ip.address:/remote_share_dir /local_share_dir

fstab:

ser.ver.ip.address:/server_dir /local_mounting_dir nfs defaults 0 0

RSYNC

Examples:

remote -> local:

rsync -rav --delete username@remote_host:/remote_dir /local_dir

local -> local:

rsync -rav --delete /local_dir_1 /local_dir_2

–delete deletes files from the destination directory if they are removed from the source directory


PROCESSES

Dynamic real-time view of processes:

top  

Search processes by name:

pgrep name_of_the_process 

List processes by user:

ps -u username 

Scroll the process list vertically and horizontally:

htop 

(apt-get install htop)

kill -9 name_of_the_process

Kill process by name without allowing process to do cleanup or restart

killall -9 PID

Kill process by PID without allowing process to do cleanup or restart


TAR

Create archive from directory or a single file:

tar -czvf archive.name.tar.gz /target.dir 

Extracts archive:

tar xzvf archive.name.tar.gz

Extracts archive in target directory:

tar xzvf archive.name.tar.gz -C /target.dir 

NETWORK INTERFACES

Lists available:

ifconfig -a 

List available with more info:

ip link show or ip addr or ls /sys/class/net 

TIME ZONE

Current time zone info:

timedatectl 

Unlink localtime file:

unlink /etc/localtime 

Seting local timezone:

ln -s /usr/share/zoneinfo/Europe/Belgrade /etc/localtime 

To set the timezone, unlinking localtime file is necessary


MYSQL

Login:

mysql -u root -p

List databases:

MYSQL> SHOW DATABASES; 

Delete database:

MYSQL> DROP DATABASE database.name; 

Make new database:

MYSQL> CREATE DATABASE database.name; 

Make new user:

MYSQL> CREATE USER 'user.name'@localhost IDENTIFIED BY 'password'; 

List users:

MYSQL> SELECT User FROM mysql.user; 

Delete user:

MYSQL> DROP USER user.name@localhost; 

Gives all rights to user over a certain database (replace database.name with * for all databases):

MYSQL> GRANT ALL PRIVILEGES ON database.name .* TO 'user.name'@localhost IDENTIFIED BY 'password';

Refreshes privileges, a must after a change:

MYSQL> FLUSH PRIVILEGES; 

Lists user rights:

MYSQL> SHOW GRANTS FOR 'user.name'@localhost; 

Exports (dumps) the database:

mysqldump -u user.name -p database.name > export.file.name.sql 

Shows original (exported) database name:

head -n 5 export.file.name.sql 

Imports dump of some database to your database:

mysql -u user.name -p database.name < export.file.name.sql