HDD and partitions
df -h – How much free disk space is available for each mount.
mount -t auto /dev/cdrom /cdfolder – mounts cd-rom to /cdfolder
umount /cdfolder – unmounts cdfolder
fdisk -l – show hard drives and partitions
fdisk /dev/sda – start fdisk for sda hard drive
commands:
a – bootable flag
p – display partitions table
d – delete a partition
n – create a new partition
t – change partition’s ID (83 – for ext2)
q – exit without saving changes
w – save changes and exit
mkfs -t ext2 /dev/sdb1 – build an ext2 file system in an empty partition
fsck -f -y /dev/sdb1 – check and repair a file system on sdb1
Mount hdc1 partition to a /data folder automatically on boot
1. Open /etc/fstab
2. Add line: /dev/hdc1 /data ext2 defaults 1 2
3. Restart computer
badblocks -n -s -v /dev/hda – Check hda disk for bad blocks.
-n – Use non-destructive read-write mode (only if disk is not mounted). Default – non-destructive read-only test.
-s – Show progress
-v – Verbose mode
File and Folder manipulations
ls -l –block-size=1M – list files in current directory with sizes in MB (K for KB)
ls *.img | wc – count .img files current directory
cp -r /source/directory /target/directory – Copy existing folder to new location
rm -r /dirctory – Remove a directory with contents
rm * – remove all files from directory
mv old-name new-name – rename files and folders
find -name “example*” – Search for files and folders beginning “example”. Searches in in the current directory and subdirectories.
find / -name “example*” – The same as above but searches in root and all subdirectories.
find -name ‘*’ -size +500M – Search for all files larger than 500MB.
du –max-depth=1 -h – List of folders with their sizes in current directory.
du -all –max-depth=1 -h – As above, but also include files.
tar -zcvf htdocs.tar.gz htdocs – compress htdocs directory
tar -zxvf htdocs.tar.gz – extract htdocs.tar.gz file
-z Compress using gzip
-c Create archive
-v Verbose
-f Archive File name
-x Extract files
Other
ifconfig – TCP/IP network interface parameters.
su – Become super user or another user.
sudo – Execute a command as the superuser or other user.
chmod -R 777 /folder – set 777 (full) permissions for folders
Startup scripts can be placed in rc.local
it could be in /etc or /etc/rc.d
apt-get install build-essential – installs all common compilers at once
tail -f /var/log/file.log – Monitors a log file in a real time. All new added lines will be outputted on a display. To interrupt press CTRL + C
Leave a Reply