Showing posts with label Unix. Show all posts
Showing posts with label Unix. Show all posts

Friday, October 26, 2012

Linux change the speed and duplex settings of an Ethernet card

Task: Get speed and other information for eth0


# ethtool eth0


Output:
Settings for eth0:    
Supported ports: [ TP MII ]   
Supported link modes:   10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full    
Supports auto-negotiation: Yes      
Advertised link modes:  10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full     
Advertised auto-negotiation: Yes      
Speed: 100Mb/s      
Duplex: Full      
Port: MII      
PHYAD: 32      
Transceiver: internal      
Auto-negotiation: on      
Supports Wake-on: pumbg      
Wake-on: d      
Current message level: 0x00000007 (7)      
Link detected: yes  
Task: Change the speed and duplex settings
Setup eth0 negotiated speed with ethtool# ethtool -s eth0 speed 100 duplex full
# ethtool -s eth0 speed 10 duplex halfTo make these settings permanent you need to create a shell script and call from /etc/rc.local(Red Hat) or if you are using Debian create a script into the directory /etc/init.d/ directory and run update-rc.d command to update the script. 


Thursday, August 23, 2012

Linux change the speed and duplex settings of an Ethernet card

Task: Get speed and other information for eth0

Type following command:
# ethtool eth0Output:

Settings for eth0:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full
Advertised auto-negotiation: Yes
Speed: 100Mb/s
Duplex: Full
Port: MII
PHYAD: 32
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: pumbg
Wake-on: d
Current message level: 0x00000007 (7)
Link detected: yes

Task: Change the speed and duplex settings

Setup eth0 negotiated speed with ethtool# ethtool -s eth0 speed 100 duplex full
# ethtool -s eth0 speed 10 duplex half
To make these settings permanent you need to create a shell script and call from /etc/rc.local(Red Hat) or if you are using Debian create a script into the directory /etc/init.d/ directory and run update-rc.d command to update the script.

Read man page of ethtool for more information.

Monday, July 2, 2012

Search and remove files - UniX (find) - Getting error: argument list too long


Q. How do I find and delete files under Linux / UNIX operating systems when I get "argument list too long"?
A. Some time it is necessary to find out files and remove them. However, rm command does not support search criteria.
However, with find command you can search for files in a directory and remove them on fly.
You need to combine find and rm command together.
Fortunately find command makes this operation quite easy. You can use find command as follows:

Linux or UNIX - Find and remove file syntax

To remove multiple files such as *.jpg or *.sh with one command find, use
find . -name "FILE-TO-FIND"-exec rm -rf {} \;
OR
find . -type f -name "FILE-TO-FIND" -exec rm -f {} \;
The only difference between above two syntax is that first command can remove directories as well where second command only removes files.

More Examples of find command

(a) Find all files having .bak (*.bak) extension in current directory and remove them:
$ find . -type f -name "*.bak" -exec rm -f {} \;
(b) Find all core files and remove them:
# find / -name core -exec rm -f {} \;
(c) Find all *.bak files in current directory and removes them with confirmation from user:
$ find . -type f -name "*.bak" -exec rm -i {} \;
Output:
rm: remove regular empty file `./data0002.bak'? y
rm: remove regular empty file `./d234234234fsdf.bak'? y
rm: remove regular empty file `./backup-20-10-2005.bak'? n
Caution: Before removing file makes sure, you have backup of all-important files. 
Do not use rm command as root user it can do critical damage to Linux/Unix system.

Friday, June 29, 2012

Command to Compress/Uncompress tar.gz and tar.bz2 files


Compress folder Test/ to Test.tar.gz

tar czfv Test.tar.gz Test/
czfv = ‘Compress Zip File Verbose’
If you want bzip files, use ‘j’ instead of ‘z’.

Uncompress Test.tar.gz to folder Test/

tar -xzf Test.tar.gz
x = ‘eXtract’
Again, if you want bzip files, use ‘j’ instead of ‘z’.