What *nix commands do you want to know more about?

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
With all of the *nix newbies popping up, it might be helpful to toss out some more information on *nix commands. The idea that the man pages aren't really newbie friendly pops up from time to time both here and other locations.

Maybe every couple of days I can post some more in depth information (maybe including useful examples) of some *nix commands. I use a variety of systems, so I'd probably try to keep it OS agnostic.

Any suggestions on commands people would like to know more about?
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: The Linuxator
Explain bash for me please I am all ears ;)

I've got a bunch of little scripting "tips and tricks" on my USB thumbdrive. I planned on posting them in some sort of context. ;)

Although, they aren't really bash related per say... :Q
 

nweaver

Diamond Member
Jan 21, 2001
6,813
1
0
some basic VI commands are helpful. Once you are in VI, there are "modes" such as (the most commen) "insert" which you get to by pressing the "i" key (you should see "insert" at the bottom). To get out of insert mode (and run other commands) use the Escape key. Pressing the : key will let you enter commands, such as save :)w) quit (q). to write changes and quit, :wq, to quit without saving, it's q!. From normal mode, typing a "/" will let you search for stuff (so to search for "log" you would type "/log"). Hitting the n key would take you to the next instance found.
 

nweaver

Diamond Member
Jan 21, 2001
6,813
1
0
command -? or --help, -h is often a quick hint option for almost all commands. Often helps to figure out a quick switch.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
vi's probably a good one. I wonder how many good tutorials are out there for it though. :p
 

The Linuxator

Banned
Jun 13, 2005
3,121
1
0
Originally posted by: n0cmonkey
Originally posted by: The Linuxator
Explain bash for me please I am all ears ;)

I've got a bunch of little scripting "tips and tricks" on my USB thumbdrive. I planned on posting them in some sort of context. ;)

Although, they aren't really bash related per say... :Q


:(
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: The Linuxator
Originally posted by: n0cmonkey
Originally posted by: The Linuxator
Explain bash for me please I am all ears ;)

I've got a bunch of little scripting "tips and tricks" on my USB thumbdrive. I planned on posting them in some sort of context. ;)

Although, they aren't really bash related per say... :Q


:(

I use (fairly regularly) Solaris, Linux, OpenBSD, and Mac OS X. Limitting myself to bash would be a shame, and force me to install it everywhere. Instead I go for portability and focus on Bourne style scripting in general.

I miss out on some probably powerful features that bash can provide, but I'll have less issues moving my script between systems.

My stuff will apply to bash, but it generally won't contain bash-isms. :)
 

nweaver

Diamond Member
Jan 21, 2001
6,813
1
0
for most distros (think this might even work in Redhat/FC, not sure though) to start/restart/stop services, you can type /etc/init.d/<Servicename> START/STOP/RESTART

for example, to start apache, I would type /etc/init.d/apache start. Tab completion is your friend, type /etc/init.d/ <tab tab> and it will show you what files are there (that you can start).
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: nweaver
for most distros (think this might even work in Redhat/FC, not sure though) to start/restart/stop services, you can type /etc/init.d/<Servicename> START/STOP/RESTART

for example, to start apache, I would type /etc/init.d/apache start. Tab completion is your friend, type /etc/init.d/ <tab tab> and it will show you what files are there (that you can start).

That's SysV specific though.
 

birdpup

Banned
May 7, 2005
746
0
0
Sure, I have a question that I have not looked up yet.
SCO unix has a 'divvy' command for partition resizing.
Is there something similar for any of the other versions of unix?
Thanks.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
for most distros (think this might even work in Redhat/FC, not sure though) to start/restart/stop services, you can type /etc/init.d/<Servicename> START/STOP/RESTART

for example, to start apache, I would type /etc/init.d/apache start. Tab completion is your friend, type /etc/init.d/ <tab tab> and it will show you what files are there (that you can start).

RedHat/FC (and Debian if you install the sysvconfig package) have a service command that can be used to start/stop services. It's essentially the same as /etc/init.d/servicename start/stop but you just have to type 'service servicename start/stop'. And if you have the bash_completion stuff enabled that comes with Debian you can still type 'service <tab><tab>' and it'll print a list of available services to complete the command with.

Sure, I have a question that I have yet to look up yet.
SCO unix has a 'divvy' command for partition resizing.
Is there something similar for any of the other versions of unix?
Thanks.

Depends. Generally on Linux it's a two step process, first resize the filesystem and then the partition containing it. How you resize either of them depends on your setup, whether you're using LVM, md or normal partitions and what filesystem you're using.
 

rmrf

Platinum Member
May 14, 2003
2,872
0
0
Originally posted by: Zugzwang152
Originally posted by: rmrf
Originally posted by: Zugzwang152
you used to have a link in your sig with some helpful startup information... what happened to that?


http://www.i-hacked.com/content/view/85/42/

nah, not that. he had his own domain.... was it nocmonkey.org or something? had stuff written by him.

That's from his webpage, but that's all that a quick google search of n0cmonkey.net brought up.
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Can I use ifconfig to release/renew dhcp leases the same way I can use ipconfig on windows? I'm pretty sure I can't, but I'd like to know how to do it from the command line.
 

Seeruk

Senior member
Nov 16, 2003
986
0
0
Originally posted by: wkinney
ifdown eth0, ifup eth0

As a command line dimwit I am not sure of the usage but also

'dhclient eth0'

Will get you an a fresh IP, not sure whether you need to do an ifdown/up after that though.

Also in case you are using a wireless nic rather than a wired one - replace 'eth0' with 'wlan0' (in most cases)

You can also use:

ifconfig plumb <eth0, wlan0, etc> - to setup a new nic or one that has mysteriously vanished

In fact if you hate looking for and finding all those config files for the networking side of things then ifconfig can be used for setting a lot of the important things

e.g's

ifconfig wlan0 essid MYNETWORK (sets the ESSID for the specified NIC)
ifconfig wlan0 address 192.168.5.136 (sets static IP as specified)

ifconfig wlan0 essid MYNETWORK address 192.168.5.136 (sets both all on one line)


 

nweaver

Diamond Member
Jan 21, 2001
6,813
1
0
DHCP depends on your dhcp client dameon (I use dhcpcd). If I already have a dhcp address, I have to go in and delete the file and then run it again. Much easier is /etc/init.d/net.eth0 restart (assuming that adapter is setup for DHCP).
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
'dhclient eth0'

Will get you an a fresh IP, not sure whether you need to do an ifdown/up after that though.

That will work, but it won't stop the old instance of dhclient so you could end up with multiple instances of dhclient thinking they're managing the same interface.

ifconfig wlan0 essid MYNETWORK (sets the ESSID for the specified NIC)
ifconfig wlan0 address 192.168.5.136 (sets static IP as specified)

ifconfig wlan0 essid MYNETWORK address 192.168.5.136 (sets both all on one line)

ifconfig doesn't know anything about wifi, you're thinking of iwconfig.

Much easier is /etc/init.d/net.eth0 restart (assuming that adapter is setup for DHCP).

I've never seen that script before in my life, what distro is that for?
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: Nothinman
'dhclient eth0'

Will get you an a fresh IP, not sure whether you need to do an ifdown/up after that though.

That will work, but it won't stop the old instance of dhclient so you could end up with multiple instances of dhclient thinking they're managing the same interface.

I think OpenBSD's version (which FreeBSD and maybe DragonflyBSD now use) stops the old one. Not positive though, I usually pkill it first.

ifconfig wlan0 essid MYNETWORK (sets the ESSID for the specified NIC)
ifconfig wlan0 address 192.168.5.136 (sets static IP as specified)

ifconfig wlan0 essid MYNETWORK address 192.168.5.136 (sets both all on one line)

ifconfig doesn't know anything about wifi, you're thinking of iwconfig.

I think OpenBSD's ifconfig does. ;)

This is one of the problems this'll bring up I guess. Some OSes use one thing, but the rest don't. Or they modify an old thing that others haven't done.