July 2008
The Archives
-
07.17.08Roll the diceNot a command, but a fun thing anyway. What if you need a dice (as I needed the other day while trying to play a game with my friends) and you don't have one? Bash can do it: $ while true;do let dice="$RANDOM % 6"; let dice=$dice+1;echo $dice;read;clear;done Though it's a long line, this is just an infinite loop in which we use the $RANDOM bash variable which generates a random number between 0 and 32767. After that, we divide it by 6 and take the remainder (so we have a number between 0 and 5) and add 1 to shift the interval ...
-
07.16.08Creating ISO from CD/DVD# dd if=/dev/cdrom of=/tmp/mycd.ISO bs=4096 Create an ISO from a CD/DVD (Replace device name and filename as appropiate)
-
07.14.08Creating empty file with timestamp$ touch -t 0807140930 test Creates an empty file test with timestamp (YYMMDDhhmm).
-
07.05.08Finding who’s using which file descriptorsSometimes it is useful to know which processes are using a certain file. You could want to remove the file or move it, or change its name, but it's not a good idea if it's being read/written by someone else. Here is when fuser comes in hand. fuser shows the PID of the processes using a file descriptor passed as argument. $> fuser $HOME $> /home/n0str0m0: 1930c 2005c 2023c 2051c 2068c 2083c 2113c 2115c 2117c 2123c 2137c 2138c 2139c 2145c 2230c 2251c 2255c 2397c 2416c 2419c 2420c 2515c 2520c The two options I have used the most so far are: -m: tells you processes using a ...
-
07.05.08Summary of network traffic per interface$ netstat -I en1 -w 1 input (en1) output packets errs bytes packets errs bytes colls 2 0 54 2 ...
-
07.01.08Time of last system shutdown$ last -x | grep shutdown | head -1 shutdown system down 2.6.24-16 Tue Jun 24 13:31 - 15:08 (01:37) This command displays the time of the last system shutdown.