Ubuntu Useful Tips

1.  Create alias
Adding alias line at the end of the file: ~/.bashrc

alias [alias_name]='[something_you_want]'

Ex:

alias elasticsearch='~/Downloads/elasticsearch/bin/elasticsearch'

2. Tmux control terminator’s sessions
https://gist.github.com/MohamedAlaa/2961058

3. Terminator cheat sheet
http://www.knuckleheadtech.com/terminator-cheat-sheet/

4.  Check memory (RAM)

$ free -m

# To monitor memory usage with updates every five seconds.

$ watch -n 5 free

5.  Check disk size

$ df -h

6.  Remove an none-empty directory

$ rm -rf mydirectory

7.  Remove sudo prompts password for current user

$ echo "$USER ALL=(ALL:ALL) NOPASSWD: ALL" | sudo env EDITOR="tee -a" visudo

8.  Disable ipv6
+ Add these lines to /etc/sysctl.conf


#disable ipv6
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

+ Apply sysctl.conf

$ sudo sysctl -p

9.  To create symlink /opt/foo –> /usr/bin/bar, (i.e., create symlink at /opt/foo which references to file /usr/bin/bar) do (See man ln):

$ ln -s /usr/bin/bar /opt/foo

10.  To order to add additional keys to pre-existing droplets, you can paste in the keys using SSH:

$ cat ~/.ssh/id_rsa.pub | ssh root@[your.ip.address.here] "cat >> ~/.ssh/authorized_keys"

11.  To copy the files from the src location to des loacation:

$ sudo rsync -avP src_dir_path/ des_dir_path/

12.  To switch user postgres

$ sudo -i -u postgres

13.  To unfold a gzip file

$ tar xzvf latest.tar.gz

14.  To install a .deb file in the usual Ubuntu way with dpkg.

$ sudo dpkg -i your_file_here.deb

This results in your-package being installed in /usr/share/your-package/

With its configuration files placed in /etc/your-package

And its init script added in /etc/init.d/your-package.

15. Check processes of a specific port example 9001

$ sudo lsof -i :9001

16. Kill applications

$ kill pid_number

Example: kill application that has PID 1234.

$ kill 1234

$ kill -9 pid_number

Example: kill application that has PID 1234 but more extreme and forceful.

$ kill -9 1234

$ killall application_name

Example: kill application or application instance that has name firefox.

$ killall firefox

17. Copy a file from remote server

scp username@source:/location/to/file /where/to/put

General syntax of scp :

scp username@source:/location/to/file username@destination:/where/to/put

See more: man scp .

Share:

Leave a Reply

Your email address will not be published. Required fields are marked *