1. Computing & Technology

GNU/Linux Command-Line Tools Summary

From

    cannot install shred on this machine.

    You may like to try alternatives such as the DBAN project that create self-booting floppy disks that can completely erase a machines hard disk.

    You may also like to see how chattr can assist you in shredding files once they are removed (it has similar problems to shred, only ext2 and ext3 style filesystems...), please see Section 14.2 .


  • du
  •    

    Displays information about file size. Use du filename to display the size of a particular file. If you use it on directories it will display the information on the size of the files in the directory and each subdirectory.

    Options for du (use du -option(s) ):

    • -c -- this will make du print a grand total after all arguments have being processed.

    • -s -- summarises for each argument (prints the total).

    • -h -- prints things in " human readable" mode; for example printing 1M (megabyte) rather than 1,024,000 (bytes).

    Using the -hs options on a directory will display the total size of the directory and all subdirectories.

    Command syntax:


       

     du -options file_directory_or_files 

    Example:


       

     du -hs * 

    This command will list the size of all files in the current directory and it will list the size of subdirectories, it will list things in human-readable sizes using 1024 Kb is a Megabyte, M for megabyte, K for kilobyte etc.


  • file
  •    

    Attempts to find out what type of file it is, for example it may say it's: binary, an image file (well it will say jpeg, bmp et cetera), ASCII text, C header file and many other kinds of files, it's a very useful utility.

    Command syntax:


       

     file file_name 


  • stat
  •    

    Tells you detailed information about a file, including inode number creation/access date. Also has many advanced options and uses.

    For simple use type:


       

     stat file 


  • dd
  •    

    Copies data on a very low level and can be used to create copies of disks Section 20.3 and many other things (for example CD image files).

    dd can also perform conversions on files and vary the block size used when writing the file.

    Command syntax, note the block size and count are optional and you can use files instead of devices...


           Please note
            

    dd is an advanced and difficult to use command. Its also very powerful, so be careful what you do with it

    Command syntax:


       

     dd if=/dev/xxx of=/dev/xxx bs=xxxx count=x 


           Warning
            

    The command dd is used to work on a very low level. It can be used to overwrite important information such as your master-boot record or various important sections of your hard-disk. Please be careful when using it (especially when working with devices instead of files).


  • touch
  •    

    This command is used to create empty files, simply do touch file_name . It is also used to update the timestamps on files.

    touch can be used to change the time and/or date of a file:


       

     touch -t 05070915 my_report.txt[2]
     
     

    This command would change the timestamp on my_report.txt so that it would look like you created it at 9:15. The first four digits stand for May 7th (0507), in MM-DD (American style), and the last four (0915) the time, 9:15 in the morning.

    Instead of using plain numbers to change the time, you can use options similar to that of the date tool. For

©2012 About.com. All rights reserved.

A part of The New York Times Company.