The Archives
-
01.31.09Tracing an already existing process$ strace -p pid Attaches to the process with PID=pid and shows the utilization of system calls. Very useful when a process seems to be stuck and you want to know what is going on.
-
01.27.09Tracing system calls$ strace ls Traces all the system calls invoked by the process "ls" Let's say we are in directory dir and we execute ls $ ls file1 file2 And now, let's see what the command actually does: $ strace ls open(".", O_RDONLY|O_NONBLOCK|O_DIRECTORY|0x80000) = 3 getdents(3, /* 4 entries */, 4096) = 112 write(1, "file1 file2\n", 13file1 file2 ) = 13 It opens the current directory, reads the number of entries (4, this is: our two files, plus "." plus "..") and writes the result using write You should keep in mind that strace traces system ...
-
01.25.09Locking a user account# passwd -l user Locks user's account, that is, prevents user from logging in. Note: This option is available in Linux and Solaris. In Mac OS X, -l option means something different: # passwd -l location user Here, -l changes the password in location. Valid values are: file: a filename. Default is /etc/master.passwd netinfo: a domain name or server/tag pair nis: an NIS domain name opendirectory: a directory node name
-
12.22.08Disabling promiscuous mode on an interface# ifconfig eth0 -promisc Disables promiscous mode on the eth0 interface.
-
11.30.08Enabling promiscuous mode on an interface# ifconfig eth0 promisc Enables promiscuous mode the eth0 interface so that all frames arriving at the interface will be passed on to the Operating System.
-
11.12.08Viewing info about free and used system memory$ free -m total used free shared buffers cached Mem: 1003 253 750 0 41 178 -/+ buffers/cache: ...
-
11.04.08Changing the MAC address of an interface# ifconfig eth0 hw ether 11:22:33:44:FF:AA Set the hardware address of the eth0 interface (the device driver has to support this operation). The hardware class (ethernet in the example) is specified with the ether parameter.
-
10.21.08Hierarchic list of processesYou probably use the ps command a lot, but sometimes there is too much info, and somewhat disordered. It can be easily ordered with the forest option, as the following example shows: $ ps -e -o pid,args --forest PID COMMAND 2 [kthreadd] 3 \_ [migration/0] 4 \_ [ksoftirqd/0] 5 \_ [watchdog/0] [...] 1 /sbin/init 2742 /sbin/udevd --daemon [...] 6307 /usr/sbin/gdm 6310 \_ /usr/sbin/gdm 6313 \_ /usr/bin/X :0 -br -audit 0 -auth /var/lib/gdm/:0.Xauth -nolisten tcp vt7 6514 ...
-
08.04.08Generating sequence of numbers$ seq 1 5 1 2 3 4 5 Generates the sequence of numbers from 1 to 5
-
06.22.08Displaying a calendar$ cal -3 may 2008 june 2008 july 2008 mo tu we th fr sa su mo tu we th fr sa su mo tu we th fr sa su 1 2 3 4 1 ...