Some linux commands tips and tricks

Posted on September 27, 2014, 9:19 pm


I am not new to linux but i am not friendly with linux :D, within my new mission i work every day with black and white terminal screen so command line every day.
How beautiful linux is !!
Soon i might become a shell script developer ^^ or this is another challenge !! but you know i'am already fall in love with JAVA :)
Today i share with you some useful linux command :

How to KillPorcess By PortNumber ?

netstat -ap | grep :PortNumber
kill -9 PortNumber

How much do you know about VI or VIM editor ?

By using VI/VIM i can easily read a 2GB text file :) really appreciated about that and feel sorry for notepad/notepad++ :(

+ Save : Ctrl + c then type :wq then type Enter
+ Close without save : Ctr + c then type :q!
+ Find : Ctr + c then type / and the word that you want to find 

if the word contain space then use quote between the word

+ Show line number : Ctrl + c then type :set nu
+ hide line number : Ctrl + c then type :set nu!
+ hide syntax hilighting : Ctr + c then type :syntax off
+ Show syntax hilighting : Ctr + c then type :syntax on

How to count file in a directory ?

ls | wc

How to transfer file from other machine to local machine by SCP ?

Suppose that you're on your local machine, and you can access to other machine.
To copy the file form the other machine use the command line below.

scp -p ${user}@${domain}:${source} ${target}

ex : scp -p abcd@0.0.0.1:/var/wwww/html/my_import_file.zip /var/pgsql

How to decrease one day in shell script ?

echo $(date "+%Y%m")$(($(date "+%d")-1))

/!\ add slash befor the % if you put this in crontab Ex: $(date "+\%Y\%m")$(($(date "+\%d")-1))

How to import SQL file into postgresql ?

psql -U user_name -d database_name -a -f /var/pgsql/my_import_file.sql

How to connect to ORACLE from sqlplus ?

sqlplus /nolog
connect username/password@oracle_machine_name

Or

sqlplus /nolog
connect username/password@(description=(address=(protocol=TCP)(host=xxx)(port=xxx))(connect_data=(sid=xxx)))

Blog Archive

  • 2023-May (1)
  • 2023-February (1)
  • 2020-October (1)
  • 2020-May (1)
  • 2020-February (2)
  • 2019-December (5)
  • 2019-November (1)
  • 2018-July (1)
  • 2017-December (1)
  • 2017-November (1)
  • 2017-June (1)
  • 2016-September (5)
  • 2016-August (3)
  • 2016-June (1)
  • 2015-September (1)
  • 2015-May (1)
  • 2015-February (2)
  • 2014-December (1)
  • 2014-November (2)
  • 2014-September (3)
  • 2014-August (1)
  • 2014-June (1)
  • 2014-May (1)
  • 2014-March (1)
  • 2013-December (2)
  • 2013-October (2)
  • 2013-July (1)
  • 2013-June (3)
  • 2013-May (4)
  • 2013-March (1)
  • 2012-December (2)
  • 2012-November (1)
  • 2012-October (1)
  • 2012-September (2)
  • 2012-August (2)
  • 2012-July (2)
  • 2012-June (1)
  • 2012-May (2)
  • 2012-March (2)
  • 2012-February (2)
  • 2012-January (5)
  • 2011-December (2)
  • 2011-November (4)
  • 2011-October (5)
  • 2011-September (2)
  • 2011-August (1)
  • 2011-June (2)
  • 2011-May (1)
  • 2011-April (9)
  • 2011-March (3)
  • 2011-February (12)
  • 2011-January (16)
  • 2010-December (17)
  • 2010-November (6)
  • 2010-October (10)
  • 2010-September (8)