
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 |
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
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
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
List available time zones:
timedatectl list-timezones
- Europe/Belgrade
- Europe/Berlin
- Europe/Brussels
- Europe/Bucharest
- Europe/Budapest
- Europe/Chisinau
- Europe/Copenhagen
- Europe/Dublin
Set your timezone
timedatectl set-timezone your_time_zone
another way
Unlink localtime file:
unlink /etc/localtime
Seting local timezone:
ln -s /usr/share/zoneinfo/Europe/Belgrade /etc/localtime
To set the timezone this way you must unlinki localtime file