short unix commandlines
useful options to some commands
- 1 command table
- 2 2008-10-03 handy rpm commands (redhat)
- 3 2008-10-13 handy deb commands (debian)
- 4 scp(2006-09-07)
- 5 ps (2007-01-25)
- 6 convert (2007-01-25)
- 7 schedule an email (2007-03-06)
- 8 file-synchronization tool for Unix and Windows, File Synchronizer(2007-04-17)
- 9 dos2unix, unix2dos (2007-05-15)
- 10 pdftk (2007-11-29)
- 11 ssh-keygen (2008-02-24)
- 12 2008-04-07 sound
- 13 2008-04-07 iconv -- convert encoding
- 14 Filesystem
- 15 2008-05-06 show listing of last logged in users
- 16 2008-05-06 Darwin (Mac FreeBSD)
- 17 2008-05-16 convex hull/viewer
- 18 2008-12-10 commands to restart daemons on MacOSX
1 command table
2009-6-19 wiki list: http://en.wikipedia.org/wiki/List_of_Unix_utilities
2009-11-6 20 Linux System Monitoring Tools http://www.cyberciti.biz/tips/top-linux-monitoring-tools.html
| command | description | more | date_created |
|---|---|---|---|
| astyle | indentation and reformatting filters for C, C++, Java, beautify code | 2006-09-12 | |
| chfn | change real user name and information | 2008-02-27 | |
| chsh | change the default shell, need some time to take effect | ||
| deborphan | find orphaned libraries(packages) | 2006-09-06 | |
| fuser -vc filename | identify/kill processes using files or sockets | 2008-10-01 | |
| getent | get entries from administrative database | getent passwd yuhuang | |
| iostat | Report Central Processing Unit (CPU) statistics and input/output statistics for devices and partitions. | 2007-07-19 | |
| latex2html | convert a latex file to a single html file. 'latex2html -split=0 log_05.tex' | ||
| lsof | list open files | 2007-07-19 | |
| nm | list symbols from object files | 2007-07-19 | |
| nmap | Network exploration tool and security / port scanner | nmap google.com | 2008-07-23 |
| pidstat | Report statistics for Linux tasks | I/O; page faults; memory usage; threads; CPU; task-switching | 2009-5-17 |
| psmerge | merge multiple ps files into one file | psmerge q2.ps q4.ps > q2_4.ps | 2006-11-08 |
| texify | Beautify source code for use with LaTeX | 2006-09-12 | |
| vmstat | display memory/cpu info | 2008-10-01 | |
| watch | execute a program periodically | showing output fullscreen | 2008-02-27 |
| yum list | list packages on redhat system | 2006-10-05 |
2 2008-10-03 handy rpm commands (redhat)
from http://susefaq.sourceforge.net/articles/rpm.html
To query a package that has NOT been installed yet, add the -p option to the command.
| command | description | more | date_created |
|---|---|---|---|
| rpm -ivh package | install a package (i=install v=verbose h=show hash marks) | 2008-10-03 | |
| rpm -e package | uninstall (erase) a package | ||
| rpm -Uvh package | upgrade a package | ||
| rpm -Uvh --test package | test a package to see how it would install (without installing) | also checks dependencies | |
| rpm -Vvv package | verify a package (extra verbose output) | ||
| rpm -Va | verify ALL installed packages on the system | ||
| rpm -K package | verify the cryptographic signature of a package | ||
| rpm -qpl package | rpm -ql package "for uninstalled package" | ||
| rpm -qa | grep pattern | find out the package names using wildcards | ||
| rpm -ql package | What files are included in the the package | ||
| rpm -qi package | To show general info on a package | ||
| rpm -qf path/to/file | What package owns this file? | ||
| rpm -qc package | What are the config files in a package? | ||
| rpm -qd package | What are the documentation files in a package? | ||
| rpm -q --scripts package | What are the scripts in a package? | ||
| rpm -q --provides package | What services does this package provide? | ||
| rpm -q --requires package | What services does this package require? |
3 2008-10-13 handy deb commands (debian)
| command | description | more | date_created |
|---|---|---|---|
| dpkg -S filename | Search for a filename from installed packages | find out which package owns a file | |
| dpkg -L package-name | List files installed to your system from package-name | ||
| dpkg -s package-name | Report status of specified package | installed packages ONLY | |
| dpkg -l package-name-pattern | List packages matching given pattern | installed packages ONLY | |
| aptitude search package-name-pattern | Searches for packages matching one of the patterns supplied on the command line | ||
| aptitude show package-name | Displays detailed information about one or more packages | ||
| aptitude why package-name | Explains the reason that a particular package can or cannot be installed on the system | ||
| aptitude markauto/unmarkauto package-name/pattern | Mark packages as automatically/manually installed | this can't fake dependency. |
4 scp(2006-09-07)
scp asks user whether to accept the connection every time it encounters a new host. 'hpc-cmb' is different from 'hpc-cmb.usc.edu' even though they have the same ip address. I guess it's based on hostname+ip. Be careful in those scheduled jobs(non-interactive).
5 ps (2007-01-25)
display precise starting time of a process (-o lstart):
ps -o suser,pid,ppid,pcpu,pmem,stime,lstart,time,tty,args -e
2008-02-228 common syntax for linux. -e=-A=all proceses. -f=does full-format listing. OT=Sorting order by start time:
ps -ef OT
2008-02-28 common syntax for MacOS/FreeBSD. -A=information about other users' processes including those without controlling terminals. -j=extra info. -o=Display info of certain field(start time in this case):
ps -Aj -o start
6 convert (2007-01-25)
picture file format conversion:
convert figures/id_96140.png figures/id_96140.jpg
7 schedule an email (2007-03-06)
The email is scheduled to sent to someboday@gmail.com at 6pm on Mar 13th 2007:
at 6pm 031307 mail -s "Subject" somebody@gmail.com
8 file-synchronization tool for Unix and Windows, File Synchronizer(2007-04-17)
unison, http://www.cis.upenn.edu/~bcpierce/unison/, setup two roots and etc.
9 dos2unix, unix2dos (2007-05-15)
install tofrodos debian package
http://www.vim.org/tips/tip.php?tip_id=26 vi command to change '^M' to carriage return in unix, 1st \r refers to ^M. 2nd \r refers to unix carriage return:
:s/\r/\r/g
10 pdftk (2007-11-29)
Merge/concatenate PDF Documents, Split PDF Pages into a New Document, Rotate PDF Documents or Pages
11 ssh-keygen (2008-02-24)
ssh-keygen generates, manages and converts authentication keys for ssh. Example:
ssh-keygen -t dsa
12 2008-04-07 sound
record sound by commandline:
sound-recorder /tmp/test.wmv
play the recorded file:
play-sample /tmp/test.wmv
Another command pair from sox also works:
rec /tmp/test.wmv play /tmp/test.wmv
12.1 alsamixer
change the volume, etc by commandline.
13 2008-04-07 iconv -- convert encoding
Convert encoding of given files from one encoding to another
To get a list of known coded character sets:
iconv -l
Several different ways of running iconv:
iconv -f ASCII -t UTF8 <zhoudb_graphdb > zhoudb_graphdb_UTF8 iconv -f ASCII -t UTF8 zhoudb_graphdb -o zhoudb_graphdb_UTF8
14 Filesystem
14.1 2008-05-05 sshfs SSH Filesystem
http://fuse.sourceforge.net/sshfs.html
to mount a filesystem, set file owner to user 1000. the user who's executing this command has to be added to group fuse:
sshfs -o uid=1000 somebody@hostname:./dir mountpoint
to unmount the filesystem:
fusermount -u mountpoint
2008-09-09 to allow a common user to access /dev/fuse in order to use sshfs, edit /etc/group and add that username to group fuse.
14.2 2008-05-29 davfs for plone
- install package davfs2
- modify zope.conf, open the section <webdav-source-server>.
- commands:
- mount -t davfs -o uid=jeffrey,gid=jeffrey,dir_mode=775 http://localhost:WEBDAV_PORT/ /mnt/webdav_banyan/
mount -t davfs -o uid=jeffrey,gid=jeffrey,dir_mode=775 https://localhost/webdav /mnt/webdav_banyan/ shows nothing because apache webdav rewrite wasn't setup correctly.
15 2008-05-06 show listing of last logged in users
last or lastb (show all bad login attempts)
16 2008-05-06 Darwin (Mac FreeBSD)
16.1 2008-05-06 check kernel information
dmesg requires root permission.
sysctl is better. cpu, memory, net:
sysctl -a | less
16.2 2008-05-06 check running tasks
top in FreeBSD is very cumbersome. To sort the display on certain things, press o and type for example cpu. or
top -ocpu
17 2008-05-16 convex hull/viewer
- package qhull http://www.qhull.org/
- Qhull computes the convex hull, Delaunay triangulation, Voronoi diagram, halfspace intersection about a point, furthest-site Delaunay triangulation, and furthest-site Voronoi diagram. The software runs in 2-d, 3-d, 4-d, and higher dimensions. Qhull implements the Quickhull algorithm for computing the convex hull. It handles roundoff errors from floating point arithmetic. Qhull also computes volumes, surface areas, and approximations to the convex hull.
Qhull does not support constrained Delaunay triangulations, triangulation of non-convex surfaces, mesh generation of non-convex objects, or medium-sized inputs in 9-D and higher.
- Geomview http://www.geomview.org/
- for 3-D and 4-D visualization of Qhull output
18 2008-12-10 commands to restart daemons on MacOSX
18.2 SystemStarter
http://www.macosxhints.com/article.php?story=20021003061516722
Apple provides a program called SystemStarter which is used to start and stop scripts in the /System -> Library -> StartupItems and /Library -> StartupItems folders. You can use it to restart services like so:
% sudo SystemStarter restart NetInfo
Or if you've just installed GimpPrint and need to restart CUPS for it to find your printer:
% sudo SystemStarter restart PrintingServices
The one caveat is that all the start, stop, and restart options do is pass this argument to the various scripts. If the script doesn't respond to that argument, nothing happens. An example is AppServices, which controls coreservicesd. Sending stop or restart to this script has no effect.
Type man SystemStarter and browse through the various scripts to learn more about the program and the scripts.