Sep 17, 2008

Linux commands

1.showing all the process
$ top



2. to kill a process from top menu
$ kill processID



3.exit from an existing menu
$q



4.clear screen
$ clear



5.killing a process from command promt
$ pkill -9 processname (kill dile kernel er kase request, but pkill -9 is force command)
pkill -SIGKILL processname(9 is the id of SIGKILL)



6a). list of every files in the current directory
ls filename



6b). list of files with the permission
$ ls -l filename



7.running a jar file form command prompt using the stack size and other sizes
$ java -jar Xms256m Xmx256m Xss64m ./jarname.jar



8. copy a folder from desktop to pendrive
$ cp -r /home/user12/Desktop/foldername /home/media/
-r stand for recursively copying all the files in the folder



9. unzip a zip file
unzip -x zipfilename.zip



10. adding environment variable
following to commands sets ARCHDIR and PATH environmental variables for nachos
export ARCHDIR=/home/mar343/mips-x86.linux-xgcc/mips-gcc
export PATH=/home/mar343/mips-x86.linux-xgcc/mips-gcc:$PATH



11. change permission of the file
$ chmod 644 profile
this will give the read/write permission to the user and read permission to group and other users



12. copy files from a remote host
$ scp aladin@uranus.cs.drexel.edu:/Users/aladin/data/a.png /Users/reza/Desktop/
It will prompt for password for the remote user name.
To do recursively add -r after scp.



13. renaming a folder
$ mv oldname newname



14. List all the installed packages:
$ dpkg --list
list all the installed packages



dpkg --list | less
list all the installed packages with scolling up down and side navigation help allowed by less command



dpkg --list | grep -i 'http'



15. grep
General Regular ExpressionP
grep apple fin.txt: will find all the lines in the text file fin.txt that has apple in it.
grep -i apple fin.txt: will do the same thing and find all upper lower letter version of apple in fin.txt
grep -w apple *.txt will find apple as a word in all the text file in current directory.



16. | pipe command
connect multiple command



17. directory size information
$ du directoryName
$ du -c directoryName[summary of the total sizes in the end]
$ du -h directoryName[human readable form G=gigabyte M=megabyte K=kilobyte]
$ du -h -max-depth=1 /home/reza




18. Adding package name in environment variable:
$ export ROS_PACKAGE_PATH=~/ros/stacks/jsk_common:$ROS_PACKAGE_PATH



NOTICE: environment variable ROS_PACKAGE_PATH gets the value first. Then we add the old value of ROS_PACKAGE_PATH using the ':' operator. Value of environment variable is found by the $ character.



19. Changing the default editor:
      - open up the .bashrc file. vi ~/.bashrc
      - append the following line: export editor='gedit'



DON'T FORGET that you can always get the home directory just by writing '~/'. You don't have to write the tedious path '/home/your_name/'.



20. cpu information:
$ cat /proc/cpuinfo



21. find the file you are looking for:
$ locate libpng



22. find the string inside the library
$ strings /usr/lib/libstdc++.so.6 | grep GLIBCXX
Here I was looking for strings with prefix GLIBCXX

23. Memory usage: egrep --color 'Mem|Cache|Swap' /proc/meminfo

24. Memory usage
$ date; free -m


25. Video from images using ffmpeg
ffmpeg -r 24 -b 16777216 -i /home/luke/scenes/nodeParameters/preview/preview%05d.png /home/luke/Desktop/test.mp4
better reference
ffmpeg -r 10 -start_number 1 -i  %04d.png -vframes 250  dining_room_0022.mp4
-r : rate eg, 10 frames per sec here
-start_number: frame 1
-vframes: how many frames
  
26. Images from Video ffmpeg
$ ffmpeg -i manhattan_test1.wmv test%03d.jpg
reference


27. Day information of the year/month/day
$ date -d 2013-02-20
Answer: Wed Feb 20 00:00:00 EST 2013

28. Brace to create a copy for later reference.
$ cp -pv american_breakfast_at_SFO.odt{,-orig}

29. create a password hash string.
$ mkpasswd -m SHA-512 

30. Use your webcam as a mirror using mplayer
$ mplayer -vf mirror -v tv:// -tv device=/dev/video0:driver=v4l2

31.  File name with .odt extention
du -a | egrep '\.(odt)$'

32. extracting a .tgz file:
$ tar -xvf model.tgz
dont use tar -zxvf model.tgz

33. watching the copying file to the DEST folder
$ watch ls -l /DEST/
reference

34. Mounting the drive
$ sudo /bin/bash
$ ls /media/
$ mkdir /media/disk
$ mount -t ntfs-3g /dev/sda2 /media/disk -o force
Reference

35. Root access to the drive when running Ubuntu from the livecd(eg usb drive)
$ gksudo nautilus

Reference


36. single pdf from multiple docs
$ pdftk 0.pdf Md_Reza_1.pdf 2.pdf Md_Reza_3.pdf cat output Md_Reza_output.pdf


37. Change default wifi connection auto-connect:
1. choose the edit connections from the wifi icon top right. 2. select the wireless connection. 3. check the box connect automatically and for all users options and save. 4. deselect any other wifi connection whose above boxes are selected similarly.

38. snap a photo:
use vlc-player. Other options are: install software 'cheese'


39. un-installing the some libraries.
http://www.wikihow.com/Uninstall-Ubuntu-Software

40. find the installed lib* file:
$ locate libxml


41. find the file with some prefix/suffix inside some directory:
$ find  . -name '*joydeep*' |xargs -0  grep 'joydeep' 
grep : ./papers/valeso_joydeep_icra2012_kinectLocalization.pdf
./papers/valeso_joydeep_polygon_merging_iros2012_planes.pdf

Reference 

42. ps to pdf convert:
$ ps2pdf la.ps

43. root filemanger access to all volumes
$ gksudo nautilus 

43. change user ownership of the mounted file system
$ sudo chown your_user_name:your_user_name /media/New\ Volume

44.hardware details
$ sudo lshw 
 
45. See image file details
file a.png
a.png: PNG image data, 100 x 80, 8-bit grayscale, non-interlaced

46.changing forgotten password for ubuntu user account.
- get the grub menu (not exactly sure which button worked, ideally it should be holding the SHIFT key)
- enter recovery mode
- pick the option 'drop to root shell prompt'
- mount -o remount, rw / (mount the file system as read-write mode)
- chmod 640 /etc/shadow
- passwd USERNAME
- choose the new password

47. uncompressing a *.7z zipped file
install p7
$ sudo apt-get install p7zip-full

then uncompress using

$ 7za x matio.7z

48. trim the directory display info in terminal
PROMPT_DIRTRIM=1
put it in the .bashrc file.

49. add the file path from ~/.bashrc into PATH environment variable
$ source ~/.bashrc

50. deleting installed app: Open the synaptic package manager and search for the google earth package. Mark the package for complete removal and select apply.

alternately, open the .deb file you will be shown the uninstaller button.

51. changing the column number and row number of the terminal.
$ stty columns 160 rows 50


52. OpenGL version
$ glxinfo | grep "OpenGL version" 
53. switch user:
$ su mreza
Reference

54.  cuda supported gpu:
$ lspci | grep -i nvidia

55. supported version of linux:
$ uname -m && cat /etc/*release

56. linux kernel version:
$ uname -r

57. noveau present:
$lsmod | grep nouveau
If returns anything then it is present

58. Forcing to install something from .deb file after encountering error
$sudo dpkg -i teamviewer_*.deb

=>Errors were encountered while processing: teamviewer:i386
$ sudo apt-get update
$ sudo apt-get install -f

59. mount/umount:
Reference: https://www.cyberciti.biz/faq/mount-drive-from-command-line-ubuntu-linux/

60. rsync (remote versatile remote copying) (shows progress of copying 'cp' doesn't have --verbose mode)
$rsync -ah --progress source destination

Reference:

61. shutdown
$ sudo poweroff
or
$ sudo shutdown -p (shuts down now)

62. selecting 'lightdm' display manager over 'gdm3'
$ sudo dpkg-reconfigure lightdm

63. discovering bluetooth
reference:
reference:

64. change password
$sudo passwd user

65. changing gcc version
https://askubuntu.com/questions/26498/choose-gcc-and-g-version

66. version of the linux:
how-to-check-os-version-in-linux-command-line


67. remove suppressing command
$rm -rf ~/work/matlab

flag r: recursive
flag f: force warnings

68. file count in current directory
 $ ls -l | wc -l

69. "I think our server support p2p, but it's a little tricky. You can use this command to download torrent:"
$aria2c --file-allocation=none --torrent-file=yourTorrentFile.torrent --listen-port=XXXX

"For large files you will need --file-allocation=none flag to prevent pre-allocating space otherwise, it will freeze the whole server (not sure why).
Using an unused port with --listen-port flag."

70. copy by excluding a particular folder
$rsync -av --progress /SOURCE/PSMNet/* /DEST/PSMNet/ --exclude trained

71. 





No comments:

Carlo Cipolla's Laws of Stupidity

    "By creating a graph of Cipolla's two factors, we obtain four groups of people. Helpless people contribute to society but are...