Navigating The File System And Simple Commands in Linux

Posted on
  • by
  • XeroX
  • in
  • Labels: , , , , ,

  • NOTE: Only for the very fresh starters with Linux.
    As we are doing the bare minimum these are the most often used commands:
    cd = change directory
    mkdir = make directory
    rmdir = remove directory
    rm = remove file
    cp = copy
    mv = move or rename
    ls = lists directories and files
    cat = show contents file

    O.K. let's play:
    Open an console on desktop 1, open the home directory by clicking on it on desktop 2 ( there you can see and verify the commands executed on desktop 1 )


    CODE
    $ mkdir One  ( without the $ ) ( makes a dir One in your home dir )
    $ mkdir one  ( Linux is case sensitive so "One" and "one" are not the same ! )
    $ cp tessst One  ( copies the file tessst, that we made in previous Tip, to dir One )
    $ mv ssset one  ( moves the file ssset, that we made in previous Tip, to dir one )
    $ mv one One   ( moves dir one in dir One )
    $ cd One   ( see how the promt puts the current dir in in the prompt ) ( puts you in dir One )
    $ ls  ( shows you what is inside One )
    $ cat tessst  ( shows contents file tessst )
    $ rm tessst  ( removes file tessst from One dir )
    $ cd ..  ( puts you back in your home dir )
    $ rm tessst  ( removes tessst from home dir )
    $ rm -rf One  ( now all files and directories we played with are removed )

    We have a look in the filesystem:

    CODE
    $ cd  /
    $ ls
    This shows you the directories in “/“ (root filesystem): /boot, /etc, /initrd, /lost+found, /opt, /root, /tmp, /var, /bin, /dev, /home, /lib, /mnt, /proc, /sbin, /usr.

    CODE
    $ cd /mnt
    $ ls
    This shows you the mounted devices, cdrom, cdrom2, floppy, (win_c)

    CODE 
    $ cd  ( Brings you back to your /home )
    $ ls  ( What is in your home )
    $ ls -a  ( What really is in home !!  The argument “-a” shows the hidden files. Hidden files start with “.” )
    $ touch .tessst  ( Makes an empty hidden file called .tessst in /home )
    $ ls  ( You don't see .tessst )
    $ ls -a  ( You do see .tessst )
    $ rm .tessst  ( Removes the hidden file .tessst )
    $ ls -al  ( Shows you all the files in /home with their “permissions” more about that later. )

    To know more about these commands and the arguments you can give them, see: "man cd" "man cp" "man mv" etc. etc.

    0 comments:

    Post a Comment