Ubuntu power user tricks

#All these command tested on, Ubuntu 16.04 LTS till date of this blog post.

GNU/Linux, 4.15.0-47-generic, x86_64, #50~16.04.1-Ubuntu SMP machine.

1. To increase opened recent files in gedit on terminal type,

gsettings set org.gnome.gedit.preferences.ui max-recents "uint32 60"

2. Mail from command line, you need, sponge, mailutils and ssmtp .

To install sponge on a Debian-like system:

apt-get install moreutils
sudo apt install mailutils
sudo apt-get install ssmtp

open,
sudo vim /etc/ssmtp/ssmtp.conf

And add the following to the file:

AuthUser=<user>@gmail.com
AuthPass=Your-Gmail-Password
mailhub=smtp.gmail.com:587
UseSTARTTLS=YES

test it
# cat some-text-file | mail -s "Test" my.user@gmail.com

3. Test with building android, do envsetup.sh and lunch

# make -j4 showcommands &> build.log ; tail -n 100 build.log | sponge build_aosp8-tail.log | mail -s "Test log" my.user@gmail.com

4. A better command terminal tmux (you can use screen for similar functionality)

Taken from here,

https://github.com/gpakosz/.tmux

Some package commands

5. List all installed packages: apt list --install

6. Upgrade all the currently installed software packages on the system: apt-get upgrade

7. Resynchronize the package index files from the their sources specified in /etc/apt/sources.list file: apt-get update

8. Un-install software packages without removing their configuration files: apt-get remove <package-name>

9. Remove software packages including their configuration files: apt-get purge <package-name>

10. Free up the disk space by cleaning retrieved (downloaded) .deb files (packages) from the local repository: apt-get clean

11. Update package cache and checks for broken dependencies.: apt-get check

12. Searche the local repositories in the system and install the build dependencies for package: apt-get build-dep <package-name>

13. display raw information about dependencies of a particular package:  apt depends <package-name>

14. View Information About Package: apt show <package-name>

15. tmux terminal basic key shortcuts

     ctrl-a % - vertical split
     ctrl-a " - horizontal split
     ctrl-a <arrow keys> - go to desired terminal, or
     ctrl-a <1, 2 or whichever window>

16. screen session
 
Ctrl-a c Create new window (shell)
Ctrl-a ? Help (display a list of commands)
Ctrl-a Ctrl-\ Quit screen
Ctrl-a D (Shift-d) Power detach and logout
Ctrl-a d

To kill a screen session, to go to a screen session, list screen sessions :

screen -ls
# screen -r <PID>

Then issue ,

ctrl-a then :quit

or just do this,

# screen -X -S <PID>

You can't use tmux with screen as 'ctrl-a d' will kill tmux instead of detaching the screen session. Checkout this video on youtube, for similar capabilites on screen,

Good_screen_tutorial for screen tutorial.

18. Exclude specific file types

           # grep  -r "ethernet0" --exclude=\*.{dtb,tmp} .

above command will exclude .dtb and .tmp files from search.


19. Compress only contents of a directory, and put the tar in previous directory,

          # cd <path_to_dir> && tar -zcf ../<contents>.tar .  && cd -


For any issue, kindly post in comments. I hope to grow this list and thank to people who make great tools for users. Will try to post original blog links, authors or repositories.

Comments

Popular posts from this blog

dev_get_platdata understanding

Getting started with pinctrl subsystem linux

How to take systrace in android