Unix Blog !

December 9, 2007

Listing USB devices on Fedora 7

Filed under: Linux Utilities, lsusb, Unix Commands, USB — sriram003 @ 5:27 pm

lsusb command can list all usb devices found,
I had Fedora core 7(moonshine) installed and i did not find the command,

I had to install usbutils which brings the command:

[root@linuxbox ~]# yum -y install usbutils
Installed: usbutils.i386 0:0.71-2.1
Complete!

[root@linuxbox ~]# lsusb
Bus 004 Device 001: ID 0000:0000
Bus 003 Device 001: ID 0000:0000
Bus 002 Device 001: ID 0000:0000
Bus 001 Device 001: ID 0000:0000
Bus 001 Device 004: ID 07a6:8511 ADMtek, Inc. ADM8511 Pegasus II Ethernet
Bus 001 Device 003: ID 046d:c016 Logitech, Inc. M-UV69a Optical Wheel Mouse

[root@linuxbox ~]# lsusb -d 07a6:8511 -v <— gives details
Bus 001 Device 004: ID 07a6:8511 ADMtek, Inc. ADM8511 Pegasus II Ethernet
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 1.10
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 8
idVendor 0x07a6 ADMtek, Inc.
idProduct 0x8511 ADM8511 Pegasus II Ethernet
bcdDevice 1.01
iManufacturer 1 ADMtek
iProduct 2 USB To LAN Converter
iSerial 3 0001
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 39
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xa0
Remote Wakeup
MaxPower 160mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 3
bInterfaceClass 0 (Defined at Interface level)
bInterfaceSubClass 0
bInterfaceProtocol 0
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0008 1x 8 bytes
bInterval 1

SSH Tips

Filed under: Shell Script, ssh, Unix Commands — sriram003 @ 6:41 am

Pointing to some SSH tips given in Linux Magazine:

$ssh -T user@hostname

If you connect to a host this way, it will disable pseudo-tty allocation
and a command like w will not show your connection. Better add
`bash -i’ , as below.
$ssh -T user@hostname /bin/bash -i

With the below command the IP address of the system you connect to wont be
logged into known_hosts file, usually its in /root/.ssh/known_hosts.

$ssh -o UserknownHostsFile=/dev/null -T user@hostname /bin/bash -i

November 19, 2007

Linux keyboard shortcuts.

Filed under: Unix Commands — sriram003 @ 12:17 pm

Linux has many keyboard shortcuts. Knowing them makes using Linux much easier.

Console/terminal

  • CtrlAltDelete – shuts down computer
  • AltFn (F1, F2, F3,…) – switch to n-th console
  • AltLeft or AltRight – switch to next/previous virtual terminal
  • Scroll Lock – locks terminal input/output – allows to read console contents when output is going too fast. To unlock, press Scroll Lock once again.
    Alternatively, Scroll Lock can be enabled using CtrlS and disabled with CtrlQ. Try last shortcut if your console hangs for unknown reason – it happened to me many times that I’ve locked it accidentaly by pressing CTRLS.
  • ShiftPage Up and ShiftPage Down – scrolls console buffer up/down. Works also when Scroll Lock is enabled. After changing the terminal (AltFn) buffer contents is erased and it is impossible to scroll it.
  • CtrlL – screen refresh
  • CtrlC or CtrlBackslash – kills current task
  • CtrlD – stands for EOF (End-of-file). If you type it on en empty command line, it will quit bash. This is so much faster than typing exit
  • CtrlZ – pause process. Use commands: bg to run in background or fg to run in foreground.


Bash & command-line

  • CtrlA – moves cursor to beginning of command line.
  • CtrlE – moves cursor to end of command line.
  • CtrlK – clears command line from cursor position to end of line.
  • CtrlU – clears command line from cursor position to beginning of line.
  • CtrlW – clears word to the left
  • CtrlY – will paste in anything that was deleted by CtrlU or CtrlK or CtrlW
  • Tabcommand-line autocompletion. Automatically completes current command line.
    If autocompletion script is enabled, then also options and applications parameters are autocompleted.
  • CtrlR – followed by characters will do a incremental search of the previous command history

Kernel shortcuts

Following shortcuts must be enabled in kernel, they also must be enabled using proc interface (echo 1 > /proc/sys/kernel/sysrq).

  • AltSysRQS – sync all mounted filesystem. Data in buffers is immediately written to disks.
  • AltSysRQU – remounts mounted filesystems read-only
  • AltSysRQB – performs immediate reboot. Don’t do it without syncing and unmounting as it can cause massive filesystem corruption
  • AltSysRQS, then AltSysRQU, then AltSysRQB – attempts to sync all mounted filesystems, remounts them read-only and immediately reboots computer. Fastest way to reboot Linux.
  • AltSysRQH – prints out list of other SysRQ functions.

X-Windows shortcuts

  • CtrlAltPlus or CtrlAltMinus– changes screen resolution (higher/lower). Only if X-Windows server is configured for multiple resolutions.
  • CtrlAltBackspace – kill X-server. Running applications will be terminated.
  • CtrlAltEscapexkill – click an application to kill it.
  • CtrlShiftNum Lock will turn the keypad on the keyboard into the mouse, so you can control the mouse from keyboard. Keys / and * on the numpad select left mouse click and right mouse click respectively. Mouse click is done by 5 on the numpad.
  • CtrlAltFn (F1, F2, F3,…) – switches to n-th text console.

KDE shortcuts

  • CtrlAltShiftPage Down – direct shutdown
  • CtrlAltShiftPage Up – direct reboot
  • AltF2 – Starts the run command box. Type a application executable to launch it, folder name to open it, filename to use an appropriate program to launch it, url to go to it in konqueror and any of the numerous web shortcuts(gg, wp) defined by konqueror to activate them.

Do you know any other shortcuts that are worth to know?

August 15, 2007

Find command tips …

Filed under: Find command, Unix Commands — sriram003 @ 4:01 pm

Finding Max space used by Top 10 Files in MB:
============================================

[root@linuxbox Desktop]# find /tmp -type f | xargs ls -msa
| sort -rn | awk ‘{size=$1/1024;printf(“%dMb %s\n”, size,$2);}’
| head

10Mb /tmp/openldap-devel-2.3.34-0.fc7.i386.rpm,
6Mb /tmp/newtonslaw.wav
4Mb /tmp/openldap-clients-2.3.34-0.fc7.i386.rpm,
3Mb /tmp/ntfs-3g-1.516-1.fc7.i386.rpm,
2Mb /tmp/fuse-2.6.5-1.fc7.i386.rpm,
1Mb /tmp/orbit-root/bonobo-activation-server-ior,
0Mb /tmp/gconfd-root/lock/ior,
0Mb /tmp/orbit-root/bonobo-activation-register.lock,

Finding files which are more than 10 MB:
========================================

find /tmp -name “*” -size +10000k

Finding files modified 3 days ago but less than 5 days:
========================================================

find /tmp -type f -mtime +2 -mtime -5

Find files that were accessed exactly 3 days a go
==================================================
find /tmp -type f -atime 3

-atime +7: All files that were last accessed more than 7 days ago
-atime 7: All files that were last accessed exactly 7 days ago
-atime -7: All files that were last accessed less than7 days ago

To replace recursive in *.html files, with multiline support:
=============================================================
find ./dir/ -name *.html -exec perl -pi -e ‘undef $/;
s/REPLACE-THIS/WITH-THAT/s’ {} \;

Update the modification date for all files in the
current directory and below:
=================================================
find . -exec touch {} \;

Remove files in a directory that were created more
than x number of days ago (great for managing Maildir).
======================================================
find ./ -ctime +x | xargs | rm -f -r

This should delete files older than 7 days, and
print the name of each file it deletes.
=================================================
find ./ -ctime +7 -name “*.zip” -exec rm -f {} \; -ls

# If you want to be prompted before it deletes a file:
find ./ -ctime +7 -name “*.zip” -exec rm -i {} \; -ls

This will list the files with names ending in .c
and containing the word hello:
=================================================

find . -type f -name ‘*.c’ -exec grep -l hello {} /dev/null \;

Find all the files recursively that contain foo:
================================================
find . | xargs grep foo
./a:foo
./c:foo
./d:ifoo

a,c,d are the file names that contain foo

June 10, 2007

Command Line UNIX

Filed under: Unix Commands — sriram003 @ 6:02 am
——————————————————————————————————————————————-
To check the list of Interrupts (IRQ) you are using :
$ cat /proc/interrupts (Linux)
$echo ::interrupts | mdb -k (Solaris)
——————————————————————————————————————————————-
Also see Procinfo, a monitoring utility that interfaces with the Linux /proc file system, and displays data such as
CPU utilization, memory utilization, interrupts serviced and information on the modules that are currently
loaded into the kernel.
$ procinfo -h (For complete list of options)
$procinfo -m (To list Modules and Device Info.)
——————————————————————————————————————————————-
Viewing a environment of a Linux or Solaris Process :

On Solaris hosts, you can see the environment of a process by invoking pargs with the “-e” (print the environment) option:

$ pargs -e 18167

18167:  /usr/lib/ssh/sshd envp[0]: LANG=C envp[1]: PATH=/usr/sbin:/usr/bin envp[2]: SMF_FMRI=svc:/network/ssh:default envp[3]: SMF_METHOD=/lib/svc/method/sshd start envp[4]: SMF_RESTARTER=svc:/system/svc/restarter:default envp[5]: TZ=US/Eastern 

On Linux hosts, you can cat /proc/$PID/environ, where $PID is the process id you are interested in:

$ cd /proc/self

$ cat environ

USER=mattyLOGNAME=mattyHOME=/home/mattyPATH=/usr/bin:/bin:/usr/sbin:/sbin MAIL=/var/mail/mattySHELL=/bin/bashSSH_CLIENT=10.10.1.10 49550 22 SSH_CONNECTION=10.10.1.10 49550 10.10.1.11 22SSH_TTY=/dev/pts/0TERM=xterm-color 

The Solaris output is a bit prettier, but they both contain the information you need to derive the environment of a process.

——————————————————————————————————————————————-
To view the library calls (specifically malloc and free) ,

$ ltrace /bin/Your-Command

This helps you debug application Problems in Linux.

——————————————————————————————————————————————-

Debugging Hung Process :

$pstack PID (Solaris)

$gstack PID (Linux)

This helps to see which stack the application is currently running.

June 9, 2007

Changing your NIC Settings from Half to Full Duplex in Linux

Filed under: Unix Commands — sriram003 @ 10:30 am
Setting up your Linux from Half to Full Duplex
# mii-tool –force=100baseTx-HD eth1 (half duplex 100 base T)
# mii-tool –force=100baseTx-FD eth1 (Full duplex 100 base T)
# mii-tool –force=10baseT-FD eth1 (Full duplex 10 base T)
# mii-tool –force=10baseT-HD (Half duplex 10 base T)
Thanks to Walt

April 26, 2007

SUN OS Admin Commands

Filed under: Unix Commands — sriram003 @ 4:33 am

SUN OS Commands

bash-2.03$ page file-name.txt
Browse or page through a text file , just like more command.

#rup
Shows host status of remote machines

example,
bash-2.03$ rup
eqdtadm1.nam.ns up 3 days, 20:57, load average: 0.00, 0.00, 0.01
eqtmsny2-phys.n up 3 days, 6:29, load average: 0.28, 0.26, 0.26
nemap1c1.nam.ns up 3 days, 3:55, load average: 0.00, 0.01, 0.02
detnr6.nam.nsro up 85 days, 14:42, load average: 0.05, 0.05, 0.05
ptmdb2c-phys.na up 3 days, 7:06, load average: 0.06, 0.05, 0.07
ffgdb1c-2.nam.n up 96 days, 18:52, load average: 0.16, 0.18, 0.18

bash-2.03$ psrinfo -v
For Processor information on a Sun System.

bash-2.03$ showrev -p
The showrev command displays the revision of a particular patch. This helps when you install a version of the patch to check if it is the latest and/or check if it is obsolete.

bash-2.03$prstat
prtstat is top in SUN os

bash-2.03$ truss -d who
truss -d and truss -D (Solaris >= 8): These truss options show the time associated with each system call being shown by truss and is excellent for finding performance problems in custom or commercial code. For example:

plimit (Solaris >= 8):
This command displays and sets the per-process limits on a running process. This is handy if a long-running process is running up against a limit (for example, number of open files). Rather than using limit and restarting the command, plimit can modify the running process.

coreadm (Solaris >= 8): In the “old” days (before coreadm), core dumps were placed in the process’s working directory. Core files would also overwrite each other. All this and more has been addressed by coreadm, a tool to manage core file creation. With it, you can specify whether to save cores, where cores should be stored, how many versions should be retained, and more. Settings can be retained between reboots by coreadm modifying /etc/coreadm.conf.

pgrep (Solaris >= 8): pgrep searches through /proc for processes matching the given criteria, and returns their process-ids. A great option is “-n”, which returns the newest process that matches.

preap (Solaris >= 9): Reaps zombie processes. Any processes stuck in the “z” state (as shown by ps), can be removed from the system with this command.

pargs (Solaris >= 9): Shows the arguments and environment variables of a process


Night Has Ended For Another Day, Morning Has Come In A Special Way, May You Smile Like Sunny Rays,

And Leave Your Worries For Some Other Day ! Have A Nice Day….

January 3, 2007

Killing multiple process at 1 go

Filed under: Unix Commands — sriram003 @ 6:10 am

[root@sriram sriram]# ps aux | grep -i sifyd | awk ‘{print $2}’
3099
3102
3103
3118

The above will list you the total process for application sifyd.

If you wish to kill all at one go, then add the below

[root@sriram sriram]# ps aux | grep -i sifyd |
awk ‘{print $2}’ |xargs kill

November 8, 2006

Using NIS commands

Filed under: Unix Commands — sriram003 @ 4:15 am

NIS+ provides a full set of commands for administering a namespace.

nisaddcred Creates credentials for NIS+ principals and stores
them in the cred table.

nisaddent Adds information from /etc files or NIS maps into
NIS+ tables.

niscat Displays the contents of NIS+ tables.

nischgrp Changes the group owner of an NIS+ object.

nischmod Changes an object’s access rights.

nischown Changes the owner of an NIS+ object.

nischttl Changes an NIS+ object’s time-to-live value.

nisdefaults Lists an NIS+ object’s default values: domain name,
group name, workstation name, NIS+ principal name,
access rights, directory search path, and time-to-live.

nisgrep Searches for entries in an NIS+ table.

nisgrpadm Creates or destroys an NIS+ group, or displays a list of its members.
Also adds members to a group, removes them, or tests them for
membership in the group.

nisinit Initializes an NIS+ client or server.

nisln Creates a symbolic link between two NIS+ objects.

nisls Lists the contents of an NIS+ directory.

nismatch Searches for entries in an NIS+ table.

nismkdir Creates an NIS+ directory and specifies its master and replica servers.

nismkuser Creates an NIS+ user.

nisrm Removes NIS+ objects (except directories) from the namespace.
nisrmdir Removes NIS+ directories and replicas from the namespace.
nisrmuser Removes an NIS+ user.
nissetup Creates org_dir and groups_dir directories and
a complete set of (unpopulated) NIS+ tables for an NIS+ domain.
nisshowcache Lists the contents of the NIS+ shared cache maintained by
the NIS+ cache manager.
nistbladm Creates or deletes NIS+ tables, and adds, modifies or deletes
entries in an NIS+ table.
nisupdkeys Updates the public keys stored in an NIS+ object.
passwd Changes password information stored in the NIS+ passwd table.

Blog at WordPress.com.