Directories
Contents |
Making and removing directories.
Make a directory.
- The command to make a directory is
mkdir:
mkdir <directory>
If you need to make multiple directories inside each other, use the -p option:
mkdir -p some/long/directory/structure
Remove a directory.
To remove an empty directory, use rmdir:
rmdir <directory>
To remove a directory that has files:
rm -r <directory>
To do remove the directory, any subdirectories, and all contents without confirmation:
rm -rf <directory>
Disk Space.
If you want to know how much disc space you are using in your $HOME, use du:
du -sh ~
Or, to see how much you're using within a particular folder:
du -sh /path/to/folder
Disk Space on Devices.
If you want to know how much disc space left on devices:
df -h
Back-up and Restore
We’ve all made mistakes during our configuration and at some point wish we could go back in time before the mistake. Now that you have the ultimate setup that you’ve worked so hard on, how are you going to be sure you have the same setup after a system or hard drive crash? The easiest method would be to use a simple tar command, see the examples below or see man tar.
Create a gzipped tarbarll:
tar -czvf BackupFile.tar.gz /path/to/backup
- Restore from a tarball by going to the parent directory (where you want your restored directory to live), then unpack the archive:
cd /path/to/dir tar -xvzf BackupFile.tar.gz