LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-11-2009, 06:18 AM   #1
sumantamit
LQ Newbie
 
Registered: Jan 2009
Posts: 8

Rep: Reputation: 0
Command


[root@localhost ~]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:16:76:4F:E6:75
inet addr:192.168.100.18 Bcast:192.168.100.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:21
[root@localhost ~]# IP=$(ifconfig eth0 | grep "inet addr" | cut -d":" -f2 | cut -d" " -f1)
[root@localhost ~]# echo $IP
[root@localhost ~]# 192.168.100.65


I can not understand what is the function of -f2 and -f1 here ...
I want to store the Bcast : 192.168.100.555 value in 'IP' variable.
Then what is the command ?
 
Old 04-11-2009, 06:23 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
-f2 and -f1 stat for the second and the first field respectively. The field are separated by the delimiter specified with the -d option, that is a colon in the first cut, a blank space in the second one. To extract the Bcast address, you have to change the field to cut:
Code:
$ ifconfig eth0 | grep "inet addr" | cut -d":" -f3
192.168.100.255 Mask
$ ifconfig eth0 | grep "inet addr" | cut -d":" -f3 | cut -d" " -f1
192.168.100.255
$ IP=$(ifconfig eth0 | grep "inet addr" | cut -d":" -f3 | cut -d" " -f1)
$ echo $IP
192.168.100.255
The manual page of cut explains it all. Cheers!
 
Old 04-11-2009, 06:25 AM   #3
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,528

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
IP=$(ifconfig wlan0 | grep "inet addr" | cut -d":" -f3 | cut -d" " -f1)
 
Old 04-12-2009, 02:08 AM   #4
sumantamit
LQ Newbie
 
Registered: Jan 2009
Posts: 8

Original Poster
Rep: Reputation: 0
Thanks..
 
Old 04-12-2009, 02:18 AM   #5
sumantamit
LQ Newbie
 
Registered: Jan 2009
Posts: 8

Original Poster
Rep: Reputation: 0
#!/bin/bash
echo "Hi how are you "
echo $USER

I want to run this scripts at boot time.
How to do this ?
 
Old 04-12-2009, 02:23 AM   #6
custangro
Senior Member
 
Registered: Nov 2006
Location: California
Distribution: Fedora , CentOS , RHEL
Posts: 1,976
Blog Entries: 1

Rep: Reputation: 208Reputation: 208Reputation: 208
Quote:
Originally Posted by sumantamit View Post
#!/bin/bash
echo "Hi how are you "
echo $USER

I want to run this scripts at boot time.
How to do this ?
Add it to /etc/rc.local
Code:
/path/to/script.sh
Or if using Red Hat based distro man chkconfig
 
Old 04-12-2009, 02:31 AM   #7
sumantamit
LQ Newbie
 
Registered: Jan 2009
Posts: 8

Original Poster
Rep: Reputation: 0
After login root's directory explore automaticaly.
What is the problem.
 
Old 04-12-2009, 02:31 AM   #8
sumantamit
LQ Newbie
 
Registered: Jan 2009
Posts: 8

Original Poster
Rep: Reputation: 0
After login root's directory explore automaticaly.
What is the problem.
 
Old 04-12-2009, 02:46 AM   #9
sumantamit
LQ Newbie
 
Registered: Jan 2009
Posts: 8

Original Poster
Rep: Reputation: 0
can we login in the server using ssh and i dont know the passwd of the server.
 
Old 04-12-2009, 03:06 AM   #10
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
Your last questions are not related to the first one. Anyway...
Quote:
After login root's directory explore automaticaly.
What is the problem.
this is not clear at all. What do you mean for "explore automatically"? If the browser starts automatically, maybe a previous X session has been saved and the previous state is restored upon a new login. Moreover, is not a good practice to login as root in the X server for a lot of security reasons.
Code:
can we login in the server using ssh and i dont know the passwd of the server.
No. You can't, at least not in a legal way. Please, explain better this question: did you forgot your password? Is it a machine you administer or is it a remote server belonging to someone else?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: The Linux Command Shell For Beginners: Fear Not The Command Line! LXer Syndicated Linux News 0 12-22-2008 06:30 PM
Translating windows pscp command to linux scp command help robward Linux - General 2 01-17-2008 06:02 AM
startx command in FC7 reverts me back to the command prompt sriram87 Linux - Newbie 5 01-03-2008 11:18 PM
Require Linux/Perl equivalent command for windows Command alix123 Programming 7 08-19-2005 02:23 AM
Key stroke/command to shut down x and go into the command prompt screen? Fear58 Linux - General 1 07-14-2004 07:14 PM


All times are GMT -5. The time now is 06:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration