Tuesday, July 19, 2011

Few Linux Commands Copied :)

  1. copy files from one linux server to another through shell
    $ scp user@from_computer:dir/filename user@to_computer:dir/filename
  2. open shell to another linux machine from one through shell
    $ ssh user@to_computer
  3. Prints the owner of every file or directory in the current directory. The AWK syntax is simply “print the 3rd field in every line of data”
    ls -l | awk '{print $3}'
  4. To get the owner of only one file (filename):
    ls -l | grep filename | awk '{print $3}'
  5. To compress a folder:
    zip -r target.zip folder/
  6. User creation
    useradd username
  7. Change user password
    passwd username
  8. Add user to a group
    usermod -g grpname username
  9. Import SQL script to an empty mysql database
    mysql -u root -p database_name < script_file.sql
  10. Unfreeze vi editor in terminal window when frozen because of ctrl+S action
    press ctrl+q
  11. Reboot linux server remotely
    sudo reboot
  12. Shut down linux server remotely
    sudo shutdown -h now
  13. Kill a process
    top
    type k to kill a process. You will be prompted for the PID of the task, and the signal to send to it. For a normal kill, send signal 15. For a sure, but rather abrupt, kill, send signal 9. The default signal, as with kill(1), is 15, SIGTERM. This command is not available in secure mode.
    
  14. To close port – 80 in following example
    fuser -k 80/tcp
  15. To display linux distribution
    1cat /etc/issue

No comments:

Post a Comment