Get root rights for all session

sudo bash

Kill a process by its name

sudo killall PROCESS

Restart network configuration

sudo service network-manager restart

Check general logs

dmesg | tail -n 50

Display online one ls column

ls -lS | awk {'print$9'}

Manage archives

Create a tar.gz archive

tar -czf new-tar-file-name.tar.gz file1 file2 folder1 folder2

Extract a tar.gz archive

tar -xzf tar-file-name.tar.gz

Symbolic link

ln -s destinationFolder sourceFolder
ln -s /data/Téléchargements /home/guenmat/Téléchargements

SSD manual optimisation

sudo fstrim -v /
sudo fstrim -v /data

Fix aptitude

sudo fuser -cuk /var/lib/dpkg/lock
sudo rm -f /var/lib/dpkg/lock

Remove old kernels

sudo apt autoremove --purge

Remove a package and its configuration

sudo apt-get remove --purge XXX

Install all drivers

sudo ubuntu-drivers autoinstall

List all installed ppa

cat | grep ppa /etc/apt/sources.list.d/*.list


List all files containing some text

find . -name "filenames" -exec grep -i -H -n 'texttofind' {} \;
find . -name "pom.xml" -exec grep -l "<doUpdate>" {} \;
find data -name "*.db" -print

Find text in file

grep -Ril "text" .

List file having a specific size

sudo find / -name '*' -size +1G
sudo find / -name '*' -size +500M

Remove all ".svn" folders from a folder

find . -name ".svn" -exec rm -rf {} \;

Remove all "Thumbs.db" files

find . -name "Thumbs.db" -exec rm -rf {} \;


find . -name "*.opf" -exec rm -rf {} \;
find . -name "*.jpg" -exec rm -rf {} \;

Clean music:

find . -name "*.wma" -exec rm -rf {} \;
find . -name "*.mp3" -exec rm -rf {} \;

List all extensions from a folder

find . -type f -name "*.*" | awk -F. '{print $NF}' | sort -u

Detect netorks errors:

find . -name "cifs*"
find . -name "cifs*" -exec rm -rf {} \;

Read mp3 tags recursively and ouput in CSV files:

find . -name "*.mp3" | while read i; do
mp3info -p "%F;%a;%l;%n;%t;%g;%y\n" "$i"
done > /tmp/mp3tags.csv

Open SSH

When it is impossible to connect to a distant server after a fresh install, and when the error message is:

Connection reset by IP port XX

Then it is needed to type the following commands on the distant server:

sudo rm /etc/ssh/ssh_host_* && sudo dpkg-reconfigure openssh-server
sudo service sshd restart

Data transfer

Huge files

nohup scp -r user@XX.XX.XX.XX:/path/folder . > nohup.out 2>&1

Through SSH

scp -r /data/Musique/* guenmat@
scp -r /home/guenmat/Vidéos/tmp/* guenmat@éos/tmp/

Check used memory

sudo aptitude install htop
sudo htop


ps aux --sort -rss

Check empty disk space

df -h

Get the bigger files

sudo du -ch / | sort -n

Find a process accorfing to a port number

netstat -tlnp | grep num_port
netstat -lapute

Display listening ports

sudo lsof -i -P -n | grep LISTEN
sudo nmap -sT -O localhost


sudo service ufw stop
lsof -i :1025-9999 +c 15

Snap package manager

To install a package

sudo snap install --classic PACKAGE

To list all pending actions

snap changes

To cancel an action (using the ID from the previous command)

sudo snap abort ID

To find a package

sudo snap find PACKAGE

To list the isntalled package

sudo snap list

To update a package

sudo snap refresh PACKAGE

To delete a package

sudo snap remove PACKAGE

Remove Nvidia packages

sudo apt-get remove --purge '^nvidia-.*'

Kworker going crazy!

sudo bash
echo "disable" > /sys/firmware/acpi/interrupts/gpe6F