ubuntu usage tips



1. how to check ubuntu OS version (tested in 12.04)

a. uname -a



Result for 32-bit Ubuntu:

Linux discworld 2.6.38-8-generic #42-Ubuntu SMP Mon Apr 11 03:31:50 UTC 2011 i686 i686 i386GNU/Linux

whereas the 64-bit Ubuntu will show:

Linux discworld 2.6.38-8-generic #42-Ubuntu SMP Mon Apr 11 03:31:50 UTC 2011 x86_64 x86_64x86_64 GNU/Linux



or

b file /sbin/init

Result for 32-bit Ubuntu:
/sbin/init: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, stripped
whereas for the 64-bit version it would look like:
/sbin/init: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, stripped

2. install .deb package
To install a downloaded Debian (Ubuntu) package (.deb): Open Terminal and type
sudo dpkg -i DEB_PACKAGE
To remove a Debian (Ubuntu) package (.deb): 
sudo dpkg -r PACKAGE_NAME
To Reconfigure/Repair an installed Debian (Ubuntu) package (.deb): 
sudo dpkg-reconfigure PACKAGE_NAME
To install the deb package when getting error
sudo dpkg  --force-all  -i  *.deb

. untar file to desired folder
solution 1:
tar -xC path/to/folder/ -f /path/to/test.tar.gz

solution 2:
cd path/to/folder ; tar xf /path/to/test.tar.gz

4. color problem
When a new ubuntu server is setup, the default sh is use for the shell script, not bash. And this make your terminal messy. And you can not use most bash scripts. You can use 
$env
To check the "SHELL" parameter. If the value is not "/bin/bash" then you need to change it.
solution 1: using cmd as below:
$chsh
(then enter your password and state the path to the shell you want to use, generally bash path is "/bin/bash").
solution 2:
You can also change the bash in file /etc/passwd for specific user.

5. find and delete size 0 files
$find tatooine/customscripts/Cakedata/ -size 0 -print0 |xargs -0 rm 

6. bash basic cmds
Use man test to check bash basic cmds

7. kill a group of scripts matching a specific string
ps aux | grep -ie $string | awk '{print $2}' | xargs kill -9

8. show system info
landscape-sysinfo

9. grep files matching multiple strings
grep 'string1.*string2' filename

  grep files matching string1 or string2
grep -E 'string1 | string2' filename

10. add default editor for crontab
export VISUAL="vi"



Comments

Popular posts from this blog

timestamp with 16, 13 and 10 digits to Qlik date

install postgreSQL in ubuntu 16.04

install ipython in Cloudera VM using pip