LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   To undo a given bash-command (https://www.linuxquestions.org/questions/linux-newbie-8/to-undo-a-given-bash-command-159510/)

HULLU 03-18-2004 03:46 PM

To undo a given bash-command
 
Is there a common command to undo a bash-command. I know this question is crazy but you never know in Linux.
I just run “chmod a+rx /dev/ptal-printd /var/run/ptal-*” and want that command undone because my printer doesn`t work anymore. I had a look in the man-page for chmod and think the right command could be
“chmod a-rx /dev/ptal-printd /var/run/ptal-*” but I´m not sure, or are there any other command like
“undo chmod a+rx /dev/ptal-printd /var/run/ptal-*”

I have SuSE9

Bebo 03-18-2004 04:07 PM

You're correct, chmod a-rx will undo chmod a+rx.

As for your undo-tool question, I've never heard of any such thing.

HULLU 03-18-2004 04:23 PM

OK. Thanks Bebo, that did the trick.

Bebo 03-18-2004 04:29 PM

Glad I could help :) If you want to know more about how file permissions work in Linux, have a look in the LQ wiki, here and here.

iambrucelee 02-19-2010 12:36 PM

In Bash there is an undo, but its not what you think
 
this thread is a little old... but just wanted to post a reply in case someone googles it

There will probably never be a command that will achieve what is desired above, as there is no way for bash to know what the equal and opposite of every single command is. For example, if you do a 'mkdir', bash will have to know that the opposite is 'rmdir'. Its not even the same command.

Having said that, there is a way to undo what you have done in bash itself.

For example...

pretend you want to 'chmod' a bunch of directories:

$> chmod 777 ./foo ./bar ./test ./yup

then you realize you want to 'chown' them instead. So you do a 'ctrl-a' to move to the front so you can replace 'chmod' with 'chown'

instead of doing an 'alt-d' to delete the word you accidentally do a 'ctrl-k' and delete the entire line!

so to "undo" what you just did on the command line, you do a 'ctrl-x, ctrl-u' to undo the last changes. 'Ctrl-_' does the same thing.

Voila, your line magically appears back in your terminal.

chrism01 02-21-2010 08:31 PM

... and you can't undo some cmds eg rmdir
;)

catkin 02-21-2010 11:06 PM

Quote:

Originally Posted by Bebo (Post 825258)
You're correct, chmod a-rx will undo chmod a+rx.

Or not:
Code:

c@CW8:/tmp$ touch foo
c@CW8:/tmp$ chmod 700 foo
c@CW8:/tmp$ ls -l foo
-rwx------ 1 c users 0 Feb 22 09:33 foo
c@CW8:/tmp$ chmod a+rx foo
c@CW8:/tmp$ ls -l foo
-rwxr-xr-x 1 c users 0 Feb 22 09:33 foo
c@CW8:/tmp$ chmod a-rx foo
c@CW8:/tmp$ ls -l foo
--w------- 1 c users 0 Feb 22 09:33 foo
c@CW8:/tmp$



All times are GMT -5. The time now is 02:23 PM.