Tuesday, August 13, 2013

Easy tricks for your needs...

01. Remove duplicate entries (line) from the text file in Ubuntu

       sort random.txt | uniq -u > rand-shorter.txt

02. Change the folder tree rights to 777 in Ubuntu
         chmod -R 777 my_folder_name

03. MySQL data export to the database from sql file
          mysql -uroot -p -h localhost mydb < mydbbackup.sql
04. Find the running port number for given process in ubuntu
          ps -ax|grep process_name
         example:  ps -ax|grep java will list out all the process having name java

05. Kill running process
        kill -9 12344 (Here 12344 is process number given by "ps -ax|grep myprocess" command)

06. Kill a process for know port
        sudo lsof -t -i:<port-number>
        Example: sudo lsof -t -i:9000
        The result would be the process number. Then use "kill -9 <process-number>" to kill the process. Please see the (05) of the above.