LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 03-18-2004, 02:46 PM   #1
HULLU
Member
 
Registered: Mar 2004
Posts: 31

Rep: Reputation: 15
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
 
Old 03-18-2004, 03:07 PM   #2
Bebo
Member
 
Registered: Jul 2003
Location: Göteborg
Distribution: Arch Linux (current)
Posts: 553

Rep: Reputation: 31
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.
 
Old 03-18-2004, 03:23 PM   #3
HULLU
Member
 
Registered: Mar 2004
Posts: 31

Original Poster
Rep: Reputation: 15
OK. Thanks Bebo, that did the trick.
 
Old 03-18-2004, 03:29 PM   #4
Bebo
Member
 
Registered: Jul 2003
Location: Göteborg
Distribution: Arch Linux (current)
Posts: 553

Rep: Reputation: 31
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.
 
Old 02-19-2010, 11:36 AM   #5
iambrucelee
LQ Newbie
 
Registered: May 2009
Posts: 4

Rep: Reputation: 4
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.

Last edited by iambrucelee; 02-19-2010 at 11:37 AM.
 
Old 02-21-2010, 07:31 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,362

Rep: Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377
... and you can't undo some cmds eg rmdir
 
Old 02-21-2010, 10:06 PM   #7
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Quote:
Originally Posted by Bebo View Post
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$
 
  


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
How do undo MV or RM command? pogromca Linux - Newbie 8 11-26-2013 06:25 AM
bash: <command name> command not found smash Programming 5 03-13-2006 08:48 AM
The ! bash command. How do I use it? funkynesh Linux - Newbie 2 10-12-2005 08:36 PM
How do I undo last command executed? Elfking Linux - General 4 02-05-2004 01:18 AM
bash command help bobdinkel Linux - Newbie 20 07-17-2003 02:21 PM


All times are GMT -5. The time now is 04:38 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