yes — Print a string until interrupted
It prints the command line arguments, separated by spaces & followed by a newline, forever until it is killed. ‘yes’ can be used to feeds a continuous string of the character to another process and create dummy process for learning the process control.
$ yes — Prints `y’ followed by a newline until killed.
$ yes foobar — Prints foobar followed by a newline until killed.
$ yes `cat myfile` — Print myfile content until killed.
$ yes | fsck /dev/hda1 — Runs fsck non-interactively.
$ yes | rm -r mydir — Same effect as rm -rf mydir.
$ yes > /dev/null & — Dummy process. Redirects ‘y’ to null process and also runs in the background.
Read : man yes
yes, odoc, linux, gnu/linux
Most of you might have heard about the new object oriented language that is creating waves. It is said that Ruby is relatively easy to learn and program. So, why don’t you try ruby first, without installing it. Try Ruby on your browser now. There is also a 15 minute short online tutorial to try out.
ruby, object+oriented+language, ruby+on+rails
ps – Report Process Status
ps gives a snapshot of the current processes. Lot of info, like CPU and MEM Usage, PID, UID, Status,…, about the present status of the process will be available in the ps output. ps can also be used as a debugging tool.
$ ps — Show all running in the current terminal.
$ ps -h — Same as above. But with-out header.
$ ps -ux — Show all processes owned by you.
$ ps -U sbharathi — Show all processes owned by sbharathi.
$ pc -C bash — Show all process with name bash.
$ ps -C syslogd -o pid= — Print PID of syslogd.
$ ps -aux — Show all processes including daemons (without tty) with username or UID.
$ ps -jx –sort=uid,-pid — All processes will list in ascending order of UID and each users process will sorted descending order.
$ ps -o start,time,etime -p 100 — Show the current status of the process with PID 100.
$ ps -e -o pid,state,cmd — Show all processes PID, State & Command (Custom output format -o ).
$ ps -ho “Process %a with PID %p is owned by %U” — Custom output.
$ ps -x -o pid,ruser=RealUser -o comm=Command -o stat=Status — Output with custom headers.
Read : man ps
ps, odoc, linux, gnu/linux
Came across this nice tutorial on creating a web application using Common Lisp. Lisp is on my agenda of todo list and so is Ruby. But those are reserved for later. Currently I am trying my hand at web.py – a nice web framework for Python.
lisp, common+lisp, ruby, ruby+on+rails, python, web.py
Here is a funny flash commercial that persuades or rather tries to switch to Linux.
kill — Sends a signal to processes.
The command kill sends the specified signal to the specified process or process group. If no signal is specified, the TERM signal is sent. Signals are used for Inter Process Communications(IPC).
$ kill -l — Print a list of signal names with numbers.
$ kill -l SIGIO — Print the number for SIGIO signal.
$ kill -l 9 — Print the Name for the Signal number 9.
$ kill 100 200 — Send TERM signal to processes with PID 100 and 200.
$ kill -s 9 100 — Send KILL signal to process with PID 100.
$ kill -n SIGKILL 100 — Same as above
$ kill -SIGKILL 100 — Same as above.
$ kill -9 100 — Same as above.
$ kill -9 -1 — Kill all your login sessions. But Not the current one.
- Two kill commands are available. One is built-in SHELL (default) and 2nd is in /usr/bin/kill.
- We can use either Signal Name or Number.
Read : man kill, signal(7)
kill, odoc, signal, IPC, linux, gnu/linux
top — Display TOP Intensive processes
TOP provides an ongoing look at processor activity in real time. TOP list the process, which is sorted based on the CPU usage of the each task on the system. It can also sort the tasks by memory usage & run time.
$ top — List the most CPU-Intensive processes.
$ top -q — Runs with the highest possible priority.
$ top -d 6 — List will be updated every 6 Sec.
$ top -n 5 — Update the list for 5 times and then exit.
$ top -p 100 -p 200 — Monitor only process with PID 100 & 200. Maximum 20 processes can be monitored.
$ top -s — Run in secure mode (Disables the potentially dangerous interactive commands).
$ top -c — List the process with command line options instead of the command name only (default).
$ top -b -n 5 > myfile — Run in Batch mode & dump the output in myfile.
- Batch Mode is useful for sending output from top to other programs or to a file. It runs until it produces the number of iterations requested with the n option or until killed.
- TOP supports few interactive commands to change the output formats like changing update time and few actions like killing a process.
Read : man top
top, odoc, linux, gnu/linux,process
paste – Merge lines of files.
Paste writes the lines from files in parallel and sequential manner in the screen. By default, Lines will be separated by a TAB character.
$ paste f1 f2 f3 — Contents of the f1,f2 & f3 will be pasted in parallel and lines are separated by TABs.
$ paste -d’#’ f1 f2 f3 — Same as above. But # is the separator.
$ paste -d’@#’ f1 f2 f3 — Same as above. But the separator for f1 & f2 is @ and for f2 & f3 is #.
$ paste -s f1 f2 — Paste one file at a time instead of in parallel (as in above commands)
$ paste num word > myfile — Paste the content of num & word and write the output into myfile.
Read : man paste
paste, odoc, linux, gnu/linux,
fmt — Simple optimal text ForMatTer
fmt reads from the specified file arguments or stdin, and writes to stdout.
$ fmt myfile — Format myfile and max line length is 75.
$ fmt f1 f2 — Format f1 f2 and max line length is 75.
$ fmt -w 60 f1 f2 — Same as above but max line length is 60.
$ fmt -s myfile — Don’t split the small line. Useful if your file contains some sample program codes.
$ fmt -u myfile — Uniform spacing. One space between words. Two space between sentences.
$ fmt -p BB myfile — Only lines beginning with BB will be formatted.
$ fmt -t myfile — Paragraph indentation will be preserved.
Note: By default, blank lines, spaces between words, and indentation are preserved in the output; successive input lines with different indentation are not joined; tabs are expanded on input and introduced on output.
Read : man fmt
odoc, fmt, linux, gnu/linux
fold — Wrap each input line to fit in specified width.
fold wrap input lines in each input file and writes the output to standard output. `fold’ counts screen columns by default.
$ fold myfile — Fold each input line at column 80 and print in the screen/stdout.
$ fold -w 40 myfile > myfile1 — Fold each input line at column 40 and the output is redirected to myfile1.
$ fold -s -w40 f1 f2 — Fold each input line of f1 and f2 at column 40 and folding will happen at space only.
$ fold -b 40 myfile — Folds at 40th byte place.
$ fold -c 40 myfile — Folds at 40th character position.
- Normally all the above options will give same output. Difference can be felt only with multi-byte encodings, like UTF-8…
- A tab may count more than one column, backspace decreases the column count, and carriage return sets the column to zero.
Read : man fold
odoc, fold, linux, gnu/linux