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

Page 6 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.

Pandamonium

Golden Member
Aug 19, 2001
1,628
0
76
Hmmm.... that hasn't worked. I have a feeling my server (run by my school) is set to always run rm in interactive mode somehow. Is there a way to get around this? I've been using paperweights on my shift and insert keys to paste "y" and a carriage return. It works, but it's grossly inefficient, and it prevents me from touching my computer for a while. I'm not familiar with how shell scripts work, but could one be written that sends y over and over until the command is done?

edit: here's some output from ssh shell..
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: Pandamonium
Hmmm.... that hasn't worked. I have a feeling my server (run by my school) is set to always run rm in interactive mode somehow. Is there a way to get around this? I've been using paperweights on my shift and insert keys to paste "y" and a carriage return. It works, but it's grossly inefficient, and it prevents me from touching my computer for a while. I'm not familiar with how shell scripts work, but could one be written that sends y over and over until the command is done?

edit: here's some output from ssh shell..

The -f should remove the interactiveness. Try alias rm="rm -f"

You could do something like echo y | rm version.php I've used it in the past, but I think there might be an issue with it (someone mentioned an issue, but it seemed to work for me ;)).
 

maseAT

Member
Dec 19, 2005
60
0
0
how do you mount the filesystem on linux of a remote linux workstation? let's say it's called workstation3.school.edu and it want it to show up as /data/workstation3 on my linux machine.. what do i do?
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: maseAT
how do you mount the filesystem on linux of a remote linux workstation? let's say it's called workstation3.school.edu and it want it to show up as /data/workstation3 on my linux machine.. what do i do?

SMB, nfs, afs, ???

It should probably be something like mount -t nfs workstation3.school.edu:/path/to/export /data/workstation3
 

skyking

Lifer
Nov 21, 2001
22,775
5,937
146
Originally posted by: nweaver
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.

here's another handy thing in vi:

after pressing the <esc> key to get out of insert mode, you can type "yy" and "p"
to 'yank' a copy of that line and 'put' it wherever your cursor is.
This is one of the features in vi that makes it quite powerful. If you are working on firewall rules and need to only change a couple of numbers in a duplicate line or lines, it can save a ton of keyboarding.
 

cker

Member
Dec 19, 2005
175
0
0
Many commands in vi can be multiplied, too. To yank 5 lines:
5Y
To delete 20 lines
20dd
and so on. You can also paste the same yanked line repeatedly.
 

skyking

Lifer
Nov 21, 2001
22,775
5,937
146
that's how I use it, and it is a feature missing in many of the other editors.
I'll try the delete thing, there are some humoungus config files with sections I don't need to page through. I always keep a raw copy for reference though.
 

Brazen

Diamond Member
Jul 14, 2000
4,259
0
0
the trailing "&"

Such as: does is work when stringing commands together with "&&" and how do you know when the command has finished?
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: Brazen
the trailing "&"

Such as: does is work when stringing commands together with "&&" and how do you know when the command has finished?

Job control can be fun. :) I'm not sure how much is $SHELL dependant, but with ksh and bash:

When && is used the first command is run in the foreground. The command after the && depends on the first one. If the first one returns an error the second command is never run. Something like command_one & ; command_two could possibly put the first command in the background and immediately start the second command because the ; does not check if the first process errors.

When a command is put in the background (using the &) the status can be checked with the jobs command. Any commands that are currently suspended (CTRL Z should suspend a job) or running in the background.

The command fg can bring commands in the background (running or suspended) to the foreground to be run there. To use the command find out the job number with the jobs command, then issue fg %job_number. To run a suspended process in the background the bg command can be used in much the same way as the fg command.
 

Brazen

Diamond Member
Jul 14, 2000
4,259
0
0
What if I want all the commands to run in the background, but I want them to run sequentially and with error checking like with "&&"? Can that be done?
 

skyking

Lifer
Nov 21, 2001
22,775
5,937
146
Originally posted by: Brazen
What if I want all the commands to run in the background, but I want them to run sequentially and with error checking like with "&&"? Can that be done?

I would not bother with that myself. Just open up another shell and let that one go about it's thing. Go back from time to time and see how it is going:)
 

screw3d

Diamond Member
Nov 6, 2001
6,906
1
76
Originally posted by: Pandamonium
Hmmm.... that hasn't worked. I have a feeling my server (run by my school) is set to always run rm in interactive mode somehow. Is there a way to get around this? I've been using paperweights on my shift and insert keys to paste "y" and a carriage return. It works, but it's grossly inefficient, and it prevents me from touching my computer for a while. I'm not familiar with how shell scripts work, but could one be written that sends y over and over until the command is done?

edit: here's some output from ssh shell..

AFAIK interactive mode should be overridden when you use -f. Do you know what operating system is your school's server on?

Try \rm -rf ~/whatever (note the backslash) and see if that works?
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: Brazen
What if I want all the commands to run in the background, but I want them to run sequentially and with error checking like with "&&"? Can that be done?

It should be possible, but checking on the status can get cumbersome. I like skyking's suggestion, or you could write a script that echoes to a file information on what it's doing.
 

Brazen

Diamond Member
Jul 14, 2000
4,259
0
0
Originally posted by: skyking
Originally posted by: Brazen
What if I want all the commands to run in the background, but I want them to run sequentially and with error checking like with "&&"? Can that be done?

I would not bother with that myself. Just open up another shell and let that one go about it's thing. Go back from time to time and see how it is going:)
The thing is sometimes I want to run a string of commands at the end of the day so they will be finished when I get back in the morning. I would do it through ssh but I got a laptop and I usually want to pack it home. I would do it on the console, but then I would have to leave that machine logged on as su.

I would like to be able to run a string of commands that are dependant on the previous command completing, and then close down my ssh session with the programs continuing to run.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: Brazen
Originally posted by: skyking
Originally posted by: Brazen
What if I want all the commands to run in the background, but I want them to run sequentially and with error checking like with "&&"? Can that be done?

I would not bother with that myself. Just open up another shell and let that one go about it's thing. Go back from time to time and see how it is going:)
The thing is sometimes I want to run a string of commands at the end of the day so they will be finished when I get back in the morning. I would do it through ssh but I got a laptop and I usually want to pack it home. I would do it on the console, but then I would have to leave that machine logged on as su.

I would like to be able to run a string of commands that are dependant on the previous command completing, and then close down my ssh session with the programs continuing to run.

Look into screen. Login to server, launch screen, start commands, detatch screen session, go home, have beer, sleep, go back to work, login, reattach to screen session, see relevant output. Simple, fun, and one of the first packages I generally install after OS installation.
 

Brazen

Diamond Member
Jul 14, 2000
4,259
0
0
Originally posted by: n0cmonkey

Look into screen. Login to server, launch screen, start commands, detatch screen session, go home, have beer, sleep, go back to work, login, reattach to screen session, see relevant output. Simple, fun, and one of the first packages I generally install after OS installation.

Oooooooooooh, I've heard of this "screen" thing but I never really knew what it did. Now I get it. Thanks.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: Brazen
Originally posted by: n0cmonkey

Look into screen. Login to server, launch screen, start commands, detatch screen session, go home, have beer, sleep, go back to work, login, reattach to screen session, see relevant output. Simple, fun, and one of the first packages I generally install after OS installation.

Oooooooooooh, I've heard of this "screen" thing but I never really knew what it did. Now I get it. Thanks.

Once I learned the basics I decided I can't live without it. ;)