Find the answer to your Linux question:
Results 1 to 6 of 6
Hello, I've just started using Fedora 8 and am having loads of fun with it...i recently found out about alias commands and how to create them...currently i am trying to ...
  1. #1
    Just Joined!
    Join Date
    Oct 2008
    Posts
    4

    Noob needs a hand with alias commands

    Hello,

    I've just started using Fedora 8 and am having loads of fun with it...i recently found out about alias commands and how to create them...currently i am trying to make one to delete a logs directory under my /home/user/. Ive tried creating it with the format alias dellogs='rmdir -i /home/user/logs' when i issue the commands it responds with a no such directory error, not sure what i am doing wrong....and also wondering if its possible to make it a system wide command, so my brother may execute it from his account as well.

    Thanks in advanced, for any light shed on this issue.
    Last edited by S-H-A-R-P-Y; 10-22-2008 at 07:06 PM. Reason: Added more description of issue

  2. #2
    Linux Newbie
    Join Date
    Jan 2008
    Location
    UK
    Posts
    211
    Hi,
    Under bash rmdir will not delete directory unless it is empty.

    So you want to use alias dellogs='rm -r /home/user/logs'

    wowbag1

  3. #3
    Just Joined!
    Join Date
    Oct 2008
    Posts
    4
    Thanks for the reply that helped alot with my formatting, i was just wondering also if its possible to create this alias to be permanant and runable by other users....also since it deletes a file in the home dir, how would i make it so the script can del the logs dir under the current logged in users home dir?

  4. #4
    Linux Newbie
    Join Date
    Jan 2008
    Location
    UK
    Posts
    211
    Hi again, have a look at this link -it gives a very complete explanation about using alias.

    How to use the alias command, by The Linux Information Project (LINFO)

    hope this helps

    wowbag1

  5. #5
    Linux Engineer Freston's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    1,047
    The trouble is more to do with variables than with the alias mechanism as I read it.


    You want to distribute this alias under multiple users? Put it in a shared profile for example? Bash has some build in variables that help you with that.
    Code:
    ~/      # Is always the current users home dir, so...
    alias dellogs="rm -r ~/logs"
    This always points to the current users homedir. By the way, ~otheruser will always point to the homedir of otheruser.
    Can't tell an OS by it's GUI

  6. #6
    Just Joined!
    Join Date
    Oct 2008
    Posts
    4
    Thanks Very Much, Freston Works like a charm.
    Article was of assistance as well wowbag thank you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...