The following are some basic commands which may be useful in the UNIX/Linux Shell. For further examples on how to work with directories and files, view the following articles:
To show the total disk usage for your VPS or dedicated server, use
df. This will show you total, used, and available disk space. Adding the
-h flag displays the numbers in a more readable format (KB, MB, GB, and so on).
[server]$ df -h Filesystem Size Used Avail Use% Mounted on /dev/sda1 24G 4.4G 19G 20% / /dev/sda5 2.3G 1.1G 1.2G 49% /tmp /dev/sda6 51G 2.0G 48G 4% /var /dev/sdb1 3.6T 3.2T 448G 88% /home /dev/ram0 3.9M 92K 3.6M 3% /var/dovecot
Note that the output above was truncated. The actual output on DreamHost's servers can be quite a bit longer.
Your home directory and all your files are in
/home (not listed above).
In the example below, the home directory is listed, and you can see from this that 26% percent of a 30GB partition is being used.
[server]$ df -h /home Filesystem Size Used Avail Use% Mounted on /dev/sdb1 3.6T 3.2T 448G 88% /home
To get a history of recent login activity:
[server]$ last <username>
Other common commands
Decompress a ZIP Archive
If you have uploaded a ZIP archive file to your user space, you can use the
unzip command to decompress it:
[server]$ unzip filename.zip Archive: filename.zip inflating: list inflating: of inflating: files inflating: being inflating: uncompressed inflating: from inflating: the inflating: zip inflating: archive
Check if your files are correctly uploaded (check for file integrity)
If you need to upload some large files to the server, you might want to check that they are correctly uploaded with no errors. To do that, just create an MD5 file and upload it to the server, in the same folder as the files you want to check.
An MD5 file is a plain text file that contains checksums of your files so their integrity can be verified afterwards; to create it you can use any MD5 tool, like wxChecksums or the command line utility in a UNIX like system with
Once you upload the MD5 file, go to the directory that contains the files you want to verify (and where you the uploaded the MD5 file) and enter the following command:
[server]$ md5sum -c yourfile.md5 list: OK of: OK uploaded: OK files: OK being: OK verified: OK
If all of the files report OK, the upload was completely successful. If any files report FAILED, it was not.
Compress all files In a directory into a ZIP Archive
Let's imagine that you have a directory named ‘images’ and that you want all the files and subfolders (and files within subfolders etc…) to be zipped up in a single file.
[server]$ zip -r images_backup images
This creates a file named ‘images_backup.zip’ in the current folder containing everything that was in the "images" folder.
You can use the maximum compression setting in tandem with this by using:
[server]$ zip -9 -r images_backup images
- SSH overview
- UNIX commands — Working with directories
- UNIX commands — Working with files
- UNIX commands — Changing ownership
- UNIX commands — Changing permissions
- Learn UNIX in 10 Minutes Note: Not everything mentioned here can be used at DreamHost.