Tagged: linux Toggle Comment Threads | Keyboard Shortcuts

  • elguber 17:47 on 18 November 2010 Permalink | Reply
    Tags: linux   

    Unix directory 

    Lest’s have a look inside the unix directory structure.

    Directory Description
    bin Essential command binaries
    boot Static files of the boot loader
    dev Device files
    etc Host-specific system configuration
    lib Essential shared libraries and kernel modules
    media Mount point for removeable media
    mnt Mount point for mounting a filesystem temporarily
    opt Add-on application software packages
    sbin Essential system binaries
    srv Data for services provided by this system
    tmp Temporary files
    usr Secondary hierarchy
    var Variable data

    The above is the main folder structure, but there are some of those folders that we should check in deep.

    /dev/null This virtual folder discards all contents written to it.
    /usr/bin Stores the executables that are in /usr.
    /usr/lib Required libraries are stored here
    /var/log System log files
    /var/mail All incoming emails are stored
    /var/spool files in which printers are involved as spools, print jobs or other task that have been queued.
    Advertisements
     
  • elguber 12:12 on 29 May 2010 Permalink | Reply
    Tags: cisco, linux   

    Connect to CISCO router under Fedora 

    Today I will explain how to connect to a Cisco router with USB to DB9 converter in Fedora. You can use this to connect to a switch, firewall or another kind of device in which you use this cable an a terminal connection.

    Scenario:

    Machine: Dell Laptop without serial port OS: Fedora 12

    Router: Cisco 2524 IOS: 11.1

    Cable: RJ-45 to DB-9 female (management cable)

    Converter: USB to DB9

    Fist, you need a terminal software. Most common is minicom but you can use Putty. Minicom is not so friendly as Putty. I can explain both and then, you can choose ūüėČ

    Using minicom

    Install as root

    [user@localhost ~]$ su
    Password:
    [root@localhost user]# yum install minicom

    Once you have minicom installed, is time to configure the device. Before start minicom you should know in which port is installed. To get that information type:

    [root@localhost user]# dmesg | grep tty

    You will get something like:

    usb 2-2.1: FTDI USB Serial Device converter now attached to ttyUSB0

    We know that converter device is in /dev/ttyUSB0. Let’s start minicom with -s option (set-up mode). You only can start with this option as root.

    [root@localhost user]# minicom -s

    Output:

    Surfing throught the menu with the up and down keys, enter in “Serial Port setup” option.

    Output:

    Typing letters in left side you’ll enter in each option.

    Option “E” output:

    Once you have configured everything you should save with “Save setup as…” option and put a name. For example: cisco

    If you choose Exit you will be directly connected to the router, if not, choose “Exit from minicom” to close down the application.

    To start minicom with the configuration previously saved as cisco type as root:

    [root@localhost user]# minicom cisco

    That’s it!

    Using Putty

    Too simple.Install putty as root typing:

    [user@localhost ~]$ su
    Password:
    [root@localhost user]# yum install putty

    Then, start putty with

    [eduardo@localhost ~]$ putty

    Output:

    Configure serial port as before with:

    [root@localhost user]# dmesg | grep tty

    You will get something like:

    usb 2-2.1: FTDI USB Serial Device converter now attached to ttyUSB0

    In serial box type:

    /dev/ttyUSB0

    In speed box type:

    9600

    done!

     
  • elguber 22:31 on 27 May 2010 Permalink | Reply
    Tags: linux   

    Linux Commands II 

    If you want a good manual with unix commands, you have two options:

    1st – A small and quick manual within no more than 5 pages

    2nd- A list of all kind of linux commands in a book or pdf with 300 pages or more.

    If you choose first option and you use all commands in the list, you will get know in a week because of use.

    My point of view is: I like a book with thousands of commands with each explanation to review. I will never know all commands. It is stupid to know all ones when you have a good help and the most known search engine website ūüėČ Anyway, if you want to be a good administrator, you should know a long list. Each command have a list of options that you can check with:

    [user@localhost ~]$ help {command}

    or

    [user@localhost ~]$ man {command}

    That is the reason because  is not mandatory to know all commands within options.

    In this post, I will  put some interesting commands.

    TOP – Command to know the CPU usage. It displays a listing of the most CPU intensive tasks on the system.

    Tasks: 193 total,   1 running, 192 sleeping,   0 stopped,   0 zombie

    Cpu(s):  1.8%us,  1.5%sy,  0.0%ni, 96.6%id,  0.0%wa,  0.2%hi,  0.0%si,  0.0%st

    Mem:   2060700k total,  1849668k used,   211032k free,    58676k buffers

    Swap:  4194292k total,       20k used,  4194272k free,  1187076k cached


    PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND

    2658 eduardo   20   0  129m  24m  16m S  2.3  1.2   2:42.51 chrome

    3321 eduardo   20   0  354m 112m  24m S  1.7  5.6   2:10.95 firefox

    1625 root      20   0 98412  62m  17m S  1.0  3.1  63:29.99 Xorg

    4421 root      20   0  2556 1104  824 R  0.7  0.1   0:00.30 top

    3658 eduardo   20   0  115m  25m  13m S  0.3  1.3   0:09.74 chrome

    3723 eduardo   20   0 48832  12m 9212 S  0.3  0.6   0:06.31 gnome-terminal

    1 root      20   0  2024  780  580 S  0.0  0.0   0:01.14 init

    2 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kthreadd

    3 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/0

    4 root      20   0     0    0    0 S  0.0  0.0   0:00.16 ksoftirqd/0

    5 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 watchdog/0

    6 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/1

    7 root      20   0     0    0    0 S  0.0  0.0   0:00.66 ksoftirqd/1

    8 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 watchdog/1

    9 root      20   0     0    0    0 S  0.0  0.0   0:00.11 events/0

    10 root      20   0     0    0    0 S  0.0  0.0   0:01.25 events/1

    11 root      20   0     0    0    0 S  0.0  0.0   0:00.00 cpuset

    12 root      20   0     0    0    0 S  0.0  0.0   0:00.00 khelper

    13 root      20   0     0    0    0 S  0.0  0.0   0:00.00 netns

    14 root      20   0     0    0    0 S  0.0  0.0   0:00.00 async/mgr

    15 root      20   0     0    0    0 S  0.0  0.0   0:00.00 pm

    PS – Reports the process status. This command typed alone show you the current running processes.

    [user@localhost ~]$ ps
    PID TTY          TIME CMD
    3725 pts/0    00:00:00 bash
    3743 pts/0    00:00:00 ps

    Adding the following options, you can get the top 5 CPU users

    [user@localhost ~]$ ps -eo pcpu,pid,user,args | sort -k 1 -r | head -5

    %CPU   PID USER     COMMAND

    62.4  2538 user  vinagre

    4.8  2997 user  rhythmbox

    31.6  1625 root     /usr/bin/Xorg :0 -nr -verbose -auth /var/run/gdm/auth-for-gdm-LC90Bs/database -nolisten tcp vt1

    2.8  3321 user  /usr/lib/firefox-3.5/firefox http://www.google.com

    MPSTAT – Display the unilization of each CPU individually.

    [root@localhost user]# mpstat

    Linux 2.6.32.12-115.fc12.i686 (localhost.localdomain) 05/27/2010 _i686_ (2 CPU)


    11:21:15 PM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle

    11:21:15 PM  all   32.00    0.34   16.37    0.66    0.07    2.06    0.00    0.00   48.51

    This command display activities for each available processor and can be used on SMP(Multiple CPU) and UP machines, but in the latter, only global average activities will be printed:
    [root@localhost user]# mpstat -P ALL
    Linux 2.6.32.12-115.fc12.i686 (localhost.localdomain) 05/27/2010 _i686_ (2 CPU)

    11:23:43 PM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
    11:23:43 PM  all   32.06    0.33   16.44    0.65    0.07    2.08    0.00    0.00   48.37
    11:23:43 PM    0   48.16    0.37   14.58    0.82    0.05    1.24    0.00    0.00   34.77
    11:23:43 PM    1   17.44    0.30   18.13    0.49    0.08    2.83    0.00    0.00   60.73
    IOSTAT – Display CPU statistics and in/out statistics for devices and partitions. Useful to know your CPU utilization since the last reboot.
    [root@localhost user]# iostat
    Linux 2.6.32.12-115.fc12.i686 (localhost.localdomain) 05/27/2010 _i686_ (2 CPU)
    avg-cpu:  %user   %nice %system %iowait  %steal   %idle
    32.17    0.32   18.63    0.64    0.00   48.24
    Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
    sda               4.77       149.94       347.32    1680964    3893686
    sdb               0.03         0.87         0.00       9782          1
    VMSTAT – Reports information about processes, memory, paging, block IO, traps, and cpu activity.

    [root@localhost user]# vmstat 3
    procs ———–memory———- —swap– —–io—- –system– —–cpu—–
    r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
    2  0    548  52268  55060 1212524    0    0    37    81  955 1157 32 18 48  1  0
    2  0    548  54620  55464 1209524    0    0   252  4275 1769 1565 24  4 52 20  0
    1  0    548  54224  55548 1204264    0    0    37  3940 1624 1536 20  4 60 15  0
    1  0     20  52704  55600 1201252   45    0   145  3536 1258 1306  7  5 60 28  0
    TCPDUMP – Dump traffic no a network
    [root@localhost user]# tcpdump ‘tcp port pop3’ tcpdump: verbose output suppressed, use -v or -vv for
    full protocol decode listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes

    NETSTAT – Ddisplays network connections, routing tables, interface statistics, masquerade

    connections, and multicast memberships. Output of this command can be too long, but you can
    put some options to get a short result like:
    [root@localhost user]# netstat -nat | awk ‘{print $6}’ | sort | uniq -c | sort -n
    1 established)
    1 ESTABLISHED
    1 Foreign
    1 TIME_WAIT
    10 LISTEN
    51 CLOSE_WAIT
    Sources:

     
  • elguber 14:56 on 31 December 2009 Permalink | Reply
    Tags: linux   

    Linux commands “a” 

    These are the most common bash commands in linux. Some of them, depending of the distribution can¬īt be available or have been replaced for another ones.
    adduser Add a user to the system

    • Command is Centos: # useradd <username>

    This command create a user locked. To unlock the user add passwd <password>

    • Command in Debian: # adduser <username>

    addgroup Add a group to the system
    alias¬†¬†¬† Create an alias. It¬īs useful when you use commands with options

    • Example: # alias ls=’ls -l’ From now, when you type ‘ls’¬† is like ‘ls -l’

    apropos Search Help manual pages. Same as # man -k
    apt-get Search for and install software packages (Debian)
    Interesting command. This command allow you
    update – Download new list of apps
    upgrade – Upgrade the app
    install – Install new packages
    remove – Remove packages
    purge  РDelete and purge packages
    source – Download font sources
    build-dep – Configure build dependencies of font packages
    dist-upgrade – Upgrade the distribution
    clean – Delete downloaded files
    autoclean – Delete old downloaded files
    check – Check in fulfill dependencies
    awk Find and Replace text, database sort/validate/index

     
c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel