The Archives

  • 10.Mar.09
    Converting filenames to lowercase cmd | rafacas | (0)
    $ for i in *; do mv "$i" "$(echo $i|tr [:upper:] [:lower:])"; done Turns all uppercase characters in the present directory filenames into lowercase. There is no collision detection, so if some name gets repeated, the destination file will be overwritten and the first file will be lost. Use the above if you know that there will be no collisions.
  • 08.Feb.09
    Unlocking a user account cmd | rafacas | (0)
    # passwd -u user Unlocks user's account. That is, lets user log in (a locked account is one prevented from logging in).
  • 31.Jan.09
    Tracing an already existing process cmd, shell | fernape | (0)
    $ 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.
  • 27.Jan.09
    Tracing system calls shell | fernape | (0)
    $ 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 ...
  • 25.Jan.09
    Locking a user account shell | rafacas | (3)
    # 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
  • 22.Dec.08
    Disabling promiscuous mode on an interface cmd, network | rafacas | (0)
    # ifconfig eth0 -promisc Disables promiscous mode on the eth0 interface.
  • 30.Nov.08
    Enabling promiscuous mode on an interface cmd, network | rafacas | (0)
    # 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.
  • 12.Nov.08
    Viewing info about free and used system memory cmd | rafacas | (0)
    $ free -m total used free shared buffers cached Mem: 1003 253 750 0 41 178 -/+ buffers/cache: ...
  • 04.Nov.08
    Changing the MAC address of an interface cmd | rafacas | (0)
    # 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.
  • 21.Oct.08
    Hierarchic list of processes shell | rafacas | (0)
    You 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 ...