Basic File Managemant (Part-2)HARDWARE NETWORKING LINUX SOFTWAREIt Tech Technology

It Tech Technology

COMPUTER HARDWARE NETWORKING

Breaking

Home Top Ad

Post Top Ad

Thursday, January 28, 2016

Basic File Managemant (Part-2)



X.  Deleting files with rm
  • ·        You can remove or delete the specified files by using the rm command
  • ·        You must have write permission for the directory from which you want to remove the specified file
  • ·        You must use the rm command carefully if you are loffed in as root!
  • ·        Options to beused with rm command:

1.   -f: deletes write-protected files without prompting

2.   -i: asks the user before deleting files

3.   -r: Deletes files and directories recursively.


  • For example, data is cleared from/tmp, without prompting to user to delete eac.h file
       Syntax for this command is :

             $ rm –rf / tmp/*


Xi. Making Directories with mkdir

·                    You can make new directories by using the mkdir command.      The syntax to use the mkdir command is:

    Mkdir directory-names
·                 Options to be used with mkdi command:

1.   –p:Creates intervening parent directories if they don’t already exist

2.   –m: set the access permissions to mode

·        For example, to create a directory called mystuff in your home directory with permissions so that only you can write, but other users can read it, the syntax is:

           $ mkdir –m 755-/mystuff

·        To create a directory tree in /tmp using one command with three subdirectories called one, two and three, the syntax is:

           $ mkdir _p /tmp/one/two/three


Xii. Identifying Types of Files

·       

           The data in files is stored in different formats, such as executable programs and text files.

You can identify the type of a files by using the file command.  The syntax to use the file command is:

     $ file/bin/bash
/bin/bash: ELF 32-bit LSB executable, Intel80386, version 1,
Dynamically linked (uses shared libs), stripped

·        It is useful to find out whether a program is actually a script:

         $ file/usr/bin/zless
          /usr/bin/zless: Bourne shellscript text

·        If  file does not know about a specific format.  It can identify the format by using the following command:

       $ files/etc/passwd/etc/passwd: ASCII text


Xii. Changing Timestamps with touch

·        Changes the access and modification times of files

·        Creates files that do not already exist

·        Options:

1.   –a, change only the access time

2.   –m, change only the nodification time

3.   –t [YYYY] MMDDhhmm[.ss], set the timestamp of the file to the specified date and time.

4.   GNU touch has a –d option, which accepts times in a more flexible format.

·                                   For example, to change the time stamp on homework to  January 20 2001, 5:59p.m, the syntax is:

            $ touch –t 200101201759 homework
         Working with Linux supported file systems


NEXT-PART

Linux Disk Management



Post Bottom Ad