GNU/Linux Command-Line Tools Summary
   Prev
   Chapter 7. Working with the file-system
   Next
7.2. Working with files and folders
- mkdir   Â
Make a directory. Use mkdir -p to create subdirectories automatically.
  Â
   Directories are Folders
   Â
  Â
Directories are sometimes called folders in other operating systems (such as Microsoft Windows)
Examples:
  Â
mkdir -p /home/matt/work/maths
This would create the directories "work" and "maths" under matt's home directory (if matt's home directory didn't exist it would create that too).
  Â
mkdir foo
This would create a directory in the current path named "foo".
Remove/delete a file(s) or directories(s). You can use standard wildcards with this command Section 20.4.1 .
Command syntax:
  Â
rm -options file_or_folder
You can of course use standard wildcards to delete multiple files or multiple directories and files.
Use the -R or -r option to remove recursively, this removes everything within subdirectories. Also try the -f option to force removal (useful when you don't want to be prompted).
  Â
   Disabling Aliases (per execution)
   Â
  Â
On some systems such as Mandrake an alias will send rm to rm -i (prompting you for every file you wish to delete). To override this use: \rm -R directory (using the \ disables the alias for this run only)
Remove an empty directory. If you want to remove a directory with files in it type " rm -R directory", read above for information on rm -R
Command syntax:
  Â
rmdir directory
This will only remove directory if it's empty otherwise it will exit with an error message.
Move a file or a directory to a new location or rename a file/directory.
Rename example:
  Â
mv filename1 filename2
Renames filename1 to filename2.
To move a file or directory, simply type:
  Â
mv original_file_or_folder new_location
Note that this command can use standard wildcards Section 20.4.1 to move files (not for renaming).
  Â
   Move and rename
   Â
  Â
Note that you can also move and rename a file in a single command. The difference is with the destination (right hand side) you change the filename to the new name of the file.
For example typing:
  Â
mv /etc/configuration.txt /home/joe/backupconfig
This would move the file "configuration.txt" to /home/joe/ and rename it "backupconfig"
Copy a file. Has a number of useful options, such as -R (or -r ) which recursively copies directories and subdirectories.
Command syntax:
  Â
cp -options file_or_files new_location
Examples:
  Â
cp file1 file2
Simply copy file1 to file2 (in the same directory).
  Â
cp /tmp/file1 ~/file2 /mnt/win_c
Where the last option is the directory to be copied to. The above
* License

