Reallylinux.com 2012 Logo   Website for Beginning Linux Users

  Main Menu
Linux Help
Favorite Links
Our Community

  Site Search


Full text search of all of our exclusive web site articles.

Enter your search words:


  Linux Tips

  • Installation Help & Tips
  • Server Configuration Guide
  • For Guru Wanna-bees
  • Commands for Server Use


  •   And many more tips Here.


    www.reallylinux.com      

    Disk Image   

    Manipulating Directories and Files
    This page is intended to help the Linux newbie come up to speed on core file and directory commands including file permissions. Brought to you by the gang here at ReallyLinux.com. If you need more Basic Commands please click here.


    If you're a beginner, it may help you to type the command
    ls -alt to list all of your current files and directories.

    Type
    ls -alt after you try each command below to be certain it worked properly. If you already have experience with directories and files, then you may want to skip to Commands for Guru Wanna-bees.

    NOTE:
    All of these commands should work from your command prompt (regardless which shell you're using). And of course, if they don't work or help you, we appologize.

    Directory Related Commands

    Command

    Summary Use
    cd Use cd to change directories. Type cd followed by the name of a directory to access that directory. Keep in mind that you are always in a directory and can navigate to directories hierarchically above or below. Ex:
    cd games
    If the directory games is not located hierarchically below the current directory, then the complete path must be
    written out. Ex:
    cd /usr/games
    To move up one directory, use the shortcut command. Ex:
    cd ..

    Use cp -r to copy a directory and all of its contents
    Type cp -r followed by the name of an existing directory and the name of the new directory. Ex:
    cp -r testing newdir
    You must include the -r or you’ll see the following message:
    cp: testing is a directory and -r not specified.
    This command saves you time if you need to make a mirror image of a directory packed with files.


    mkdir Use mkdir to make/create a brand new directory
    Type mkdir followed by the name of a directory. Ex:
    mkdir testdir

    mv Use mv to change the name of a directory
    Type mv followed by the current name of a directory and the new name of the directory. Ex:
    mv testdir newnamedir

    pwd Trying to find out where on your Linux server you currently are located? The pwd (print working directory) command will show you the full path to the directory you are currently in. This is very handy to use, especially when performing some of the other commands on this page!

    rmdir
    Use rmdir to remove an existing directory (assuming you have permissions set to allow this).
    Type rmdir followed by a directory's name to remove it. Ex:
    rmdir testdir

    You CAN'T remove a directory that contains files with this command.

    Instead to delete non-empty directories in Linux, use the more useful command:rm -r

    This command removes directories and files within the directories. Read more details about this in Commands for Beginning Admins

    The rmdir command is used mostly to remove empty directories. If you have a desire to use this command then you'll need to delete or move the files before attempting to remove a full directory. For more help please read the mv command and also
    File Related Commands.

     


    WAIT! There are MANY more commands. This page only has items related to directories. The page related to manipulating files is: Manipulating Files.




    Need More Information or Help???


     


    For personal help or answers to questions, please visit our message boards.

    html 4145
    Copyright 2004, 2009 Mark Rais   All Rights Reserved.

    Linux is a registered trademark of Linus Torvalds.
    All other trademarks
    and registered trademarks on this entire web site are owned by their respective companies.
    This site is not related or affiliated with any other sites.