Ubuntu/Linux Cheat Sheet

Kill process

pkill -9 name*

 

Chain commands

com1; com2

 

Recursive delete folder

rm -rf dirPath

 

Change owner 

sudo chown newOwner file/dir # single file/dir

sudo chown -R newOwner dirpath # recursively

 

Restart Apache server:

sudo service apache2 restart

 

Change Anaconda Python environment:

source activate p2/p3/envName

 

Update and run startup script

gedit ~/.bashrc

source ~/.bashrc

Make Ubuntu terminal auto-complete case insensitive

Run this and restart terminal:

echo "bind 'set completion-ignore-case on'" >> ~/.bashrc

From this SO answer.

Truncate a log file (without deleting it)

truncate --size 0 file.log

Resize partitions including the swap partition

Install and run gparted

sudo apt-get install gparted

Then run from start menu by typing gparted

From: https://askubuntu.com/a/126250/702527

If needed to delete the swap partition, run the steps here to update it’s UUID:

https://askubuntu.com/questions/711016/slow-boot-a-start-job-is-running-for-dev-disk-by#753571 

Show directories broken down by file size (recursively and visually)

Install and run qdirstat

https://github.com/shundhammer/qdirstat

Get local IP address

ip route get 8.8.8.8 | awk '{print $NF; exit}'

Source

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s