System restart / reboot

 sudo systemctl reboot

Zip files in directory into its own archive

for file in your_file_name*; do zip ${file%}.zip $file; rm $file; done

Create a directory and sub directories

mkdir -p one/two/three/four

Get the size of a directory

du -sh file_path

  -s, --summarize
         display only a total for each argument

  -h, --human-readable
         print sizes in human readable format (e.g., 1K 234M 2G)

  -c, --total
         produce a grand total

Show last lines from a log file

tail -n 1000 /var/log/mail.log | more
  -n 100 = last 100 lines
  more = to be able to view file line by line

Download a file

wget <http://domane.to.file.zip> -P </path/to/folder>

Lock remote access for root user

vi /etc/ssh/sshd_config
change: "PermitRootLogin yes" -> "PermitRootLogin no"
/etc/init.d/ssh reload

Show all users (ubuntu)

cat /etc/passwd | cut -d":" -f1
(etc/shadow - users file)

Lock user for login

passwd <username> -l

unlock user for login

passwd <username> -u

Grant executing rights to the current user

chmod +x (datei)

Change folder or file owner

chown <newowner> -R /path/

-R recursive

Unpack tar-archive

tar xf [ARCHIV].tar
- x unpack
- f File

Create tar-archive

tar -cvzf /path/[ARCHIV].tgz /path/to/folde

Create a file

touch <filename>

Add user to the sudoers file

open Sudoers file (/etc/sudoers) and add:

...
# User privilege specification
<username>    ALL=(ALL:ALL) ALL

Install rpm file

sudo rpm -i <filename>.rpm

Delete file or folder

rm -rf <ordername>

delete all files in current folder

rm -rf *

-r - recursive
-f - force (delete without warnings)

show current directory

pwd

show which sub-folders spend how much disk space

du -h --max-depth=1 </folder> | sort -hr

-h, --human-readable           print sizes in human readable format