Category Archives: unix

unix – list content of tar file and extract specific file

To list content of tar.gz file: tar -tvf my-data.tar.gz ‘<looked-for-file-or-path-name>’ To extract specific cotnent from tar.gz file: tar -xvpBf my-data.tar.gz ‘<path-name>’ sources https://www.cyberciti.biz/faq/list-the-contents-of-a-tar-or-targz-file/

Feed unix pipe into ls / feed ls with pipe

To feed “ls” instruction with pipe, simply use xargs as per below: find . -type f -name mypattern* | xargs ls -l sources http://stackoverflow.com/questions/18210956/unix-pipe-into-ls

unix – split large text file into smaller one

run: split -a 5 -d -l 10000 my_file.txt my_file_ usage: split -a 5 -d -l <nb_lines_per_file> <file_to_split> <split_prefix> d = numeric numbering (instead of alphabetical) l = number of lines per split files a = number of characters used for numbering (increase it in case of exhaustion) sources https://kb.iu.edu/d/afar

unix – compare folder tree and identify files which are different

Very easy: sources diff -arq folder1 folder2 http://stackoverflow.com/questions/1644593/unix-compare-two-folders-which-has-many-files-inside-contents

unix – use ps and grep to kill processes [solved]

To kill specific processes in one go, use below syntax: kill $(ps aux | grep ‘[m]y_specific_process’ | awk ‘{print $2}’) Note: using ‘[]’ is a hack to prevent grep process from being included in returned output sources http://stackoverflow.com/questions/3510673/find-and-kill-a-process-in-one-line-using-bash-and-regex

run process in background and keep it running after ssh exit [done]

To do so, simply use “disown <pid>” command. Proceed as follows: ssh into server run command and put it in background: myprocess.sh & note the id of the command being returned (or run either “jobs -l” or “ps aux | grep myprocess” to find it back) run command: disown <pid> exit ssh ssh into server again run “ps aux | grep <pid>” should return content Alternatively use “nohup”: simply prefix your command with “nohup” example: nohup myprocess.sh & sources http://www.cyberciti.biz/faq/unix-linux-disown-command-examples-usage-syntax/ http://stackoverflow.com/questions/5164985/how-can-i-use-nohup-to-run-process-as-a-background-process-in-linux http://unix.stackexchange.com/questions/3886/difference-between-nohup-disown-and http://askubuntu.com/questions/8653/how-to-keep-processes-running-after-ending-ssh-session

unix – file cannot be deleted or modified, even by root user [solved]

I had a file that could not be edited / removed / moved, even by root user. Reason for it is that this file was declared immutable. To solve this, run: sudo chattr -i <path/to/file> Now file can be edited/removed/moved. sources http://www.omgubuntu.co.uk/2016/03/fix-failed-to-fetch-google-chrome-apt-error-ubuntu  

ubuntu with gnome 3 – change login screen logo [solved]

To change login screen logo on ubuntu with gnome 3, proceed as follows: sudo apt-get install dconf-editor open dconf-editor as root: sudo dconf-editor navigate to org > gnome > login-screen update value of “logo” variable to the path of logo file to use restart GDM And voilà! sources http://ubuntuhandbook.org/index.php/2014/04/ubuntu-14-04-change-login-screen-background-remove-the-white-dots/ http://stackoverflow.com/questions/29189648/why-cant-i-change-the-gnome-login-screen-logo  

ubuntu – install all google fonts and use them in gimp

To install all google fonts in gimp on ubuntu, proceed as follows: download fonts from https://github.com/google/fonts/archive/master.zip create a folder “.fonts” in your home directory: mkdir ~/.fonts unzip content of downloaded file into newly created .fonts folder: cd ~/.fonts; unzip ~/Downloads/master.zip regenerate font cache: sudo fc-cache -fv restart gimp That’s it. All fonts should be avaialable sources https://github.com/google/fonts/ http://askubuntu.com/questions/3697/how-do-i-install-fonts https://wiki.ubuntu.com/Fonts https://www.google.com/fonts

gnome – change default screenshot program

Default screenshot program is easy to use and does the job. If you want to go slightly forward, such as selecting screenshot area, editing screenshot and so on, you should give a go to “shutter” as an alternative. steps install shutter: sudo apt-get install shutter set up shutter as default application go to keyboard shortcuts under tab “Customs Shortcuts” create a new shortcut running “shutter -s”, as per below assign the print-screen button as activation button for this shortcut, as per below done! sources http://askubuntu.com/questions/252717/how-to-make-shutter-as-the-default-screenshot-tool