Advertisement
Guest User

Untitled

a guest
Feb 12th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. *********************************** Ubuntu terminal tips ***********************************
  2. *********************************** Author: Pallavi Patni **********************************
  3.  
  4. Linux Tips
  5. ----------
  6. 1. To kill xsp server-
  7. kill `ps aux|grep xsp4.exe|grep -v grep|awk '{print $2}'`
  8.  
  9. 2. To kill a process-
  10. display all currently running processes: ps -ef
  11. kill particular process: kill [processID] ; processID can be viewed from the above command
  12.  
  13. 3. To remove non-empty directory-
  14. rm -rf foldername
  15.  
  16. note: rf is for recursive removal of files and the directory
  17.  
  18. 4. To get the count of Terminal-windows open-
  19. who|grep "pts"|wc -l
  20.  
  21. 5. View/Change system's datetime-
  22. view- date
  23. change- date MMddHHmmyyyy.ss
  24.  
  25. 6. make softlinks (aka symbolic links, symlinks; aka virtual folders in MS windows)
  26. ln -s /[folder-path] /[softlink-foldername]
  27.  
  28. 7. Read physcial path (actual path) of a softlink-
  29. readlink -f [softlink-path]
  30.  
  31. 8. To run a program in background, even if the Terminal gets closed (deliberately or whatever)-
  32. setsid[ProgramName]
  33. e.g., setsid gnome-calculator
  34. (alternative to setsid is nohup)
  35.  
  36. 9. shutoff/restart system-
  37. sudo poweroff
  38. sudo reboot
  39.  
  40. 10. go to Task-manager-
  41. gnome-system-monitor
  42.  
  43. 11. Use sudo's pwd in single command (without shell to prompt for pwd)-
  44. $sudo -S <<< 'your_pwd' [command]
  45. e.g., $sudo -S <<< 'pppp' chmod 777 /home/administrator/myfolder/myfile.txt
  46.  
  47. 12. Execute a shell script-
  48. #sh myscript.sh[arg1,arg2,..]
  49.  
  50.  
  51. Errors with solutions
  52.  
  53. 1. sudoers are world-writable; i.e., full permissions are given to /etc/ and you cannot login to terminal as sudo; hence cannot change its permissions;
  54. $pkexec chmod 0440 /etc/sudoers
  55.  
  56. 2.
  57.  
  58.  
  59. MySQL Tips
  60. ----------
  61. 1. Check hosts-
  62. select host from mysql.user where user ='root';
  63.  
  64. 2. Make one server's (or machine's) MySQL to get instantiated from other MySQLs (on other servers)-
  65. Open file /etc/mysql/my.cnf & change '127.0.0.1' under element 'bind-address' to the IP of the server & restart MySQL service
  66.  
  67. 3. change password for root in MySQL-
  68. use mysql;
  69. update user SET password = password('new-password')
  70. WHERE host= 'localhost' AND user = 'root' ;
  71.  
  72. and for setting password for remote access as well-
  73. update user SET password = password('new-password')
  74. WHERE host= '%' AND user = 'root' ;
  75.  
  76. 4. Execute a MySQL query through command-line-
  77. #mysql -u[username] -p[password] [dbname]<query.sql> output.tab;
  78.  
  79. 5. If you don't want to type the username and password in the command-line statements, save it in the my.cnf file, as follows:
  80. in the [client] element in my.cnf, user = [username]
  81. password = [password]
  82.  
  83. 6. Getting the result of a MySQL command to a file
  84. mysql -host[ip-address] -p[password] <query.sql> > filename.log 2>&1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement