msgbartop
A cronological documentation test project, nothing serious, really!
msgbarbottom

04 Sep 2008 Share a bash session using screen

This is a short post on how you can “share” a bash session/prompt with other users.

  1. User A connects to the server and types in the command
    # screen
  2. User A hist the key combination <Ctrl + a> and the type
    :multiuser on
  3. User B connects to the same server as user A and can the join the session by typing
    # screen -x

Serveral users can connect and share the same session at once.

To close the screen session just use the key combination <Ctrl + a>

Tags: ,

Posted by

23 Jun 2008 Oneliner to determine directory size

This is a simple oneliner to determine which user has used most diskspace in their /home directory

du -sm $(find /home -type d -maxdepth 1 -xdev) | sort -g

The result could look something like this

...
215     /home/userT
1367    /home/userB
10865   /home/userL
25326   /home/userY
116328  /home/userH
154426  /home/

The numbers to the left is size i MB.

Tags:

Posted by

03 Jun 2008 Generate a /etc/hosts file from the command line

This is a simple example of how you can populate a /etc/hosts file with 100 IPs and hosts from the command line

# N=1; for i in $(seq -w 100); do echo "192.168.99.$N host$i"; P=$(expr $P + 1); done >> /etc/hosts

The result file /etc/hosts

192.168.99.201 host001
192.168.99.201 host002
192.168.99.201 host003
192.168.99.201 host004
192.168.99.201 host005
192.168.99.201 host006
192.168.99.201 host007
192.168.99.201 host008
192.168.99.201 host009
192.168.99.201 host010
192.168.99.201 host011
192.168.99.201 host012
192.168.99.201 host013
192.168.99.201 host014
192.168.99.201 host015
192.168.99.201 host016
192.168.99.201 host017
192.168.99.201 host018
192.168.99.201 host019
192.168.99.201 host020
...

Tags:

Posted by

25 Feb 2008 My 10 most used linux commands

This is a oneliner bash command to determine my 10 most used linux commands according to my history file

history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl |  head -n10

The result

     1  188  37.6%  vi
     2  38   7.6%   ls
     3  24   4.8%   cat
     4  22   4.4%   apt-get
     5  12   2.4%   date
     6  11   2.2%   tail
     7  11   2.2%   cd
     8  10   2%     rm
     9  10   2%     man
    10  9    1.8%   basename

It looks like i use vim a lot on my home server. You should try it yourself and see what commands you use the most.

Source: http://linux.byexamples.com

Tags: , , , , , ,

Posted by

21 Feb 2008 Apache web connections pr hour

This is a bash oneliner to show Apache web connections pr hour. It lists up the IPs that has accessed your webserver and the amount og accesses.

# cat /var/log/apache2/access_log_pario.no | grep "21/Jan/2008:.." | awk {' print $4":"$1 '} | sed 's/\[//g' | awk -F : {' print $1":"$2"\t\t"$5 '} | sort | uniq -c

Example output

37 21/Jan/2008:00          192.168.0.10

This shows that I had 37 hits from 00:00 – 01:00 in 20th February 2008.

Tags: , , , ,

Posted by