Terminal

Terminal commands

File commands

ls: show files & folders:
options: l: show also permissions and owner
Remove: rm [filename]
Copy: cp [source] [destination]
Move/rename: mv [source] [destination]
Find: locate [filename]
Make directory: mkdir [dirname]
Remove directory: rmdir [dirname] (should be empty, if not empty: use rm -rf folder_name)

Fdisk: overzicht partities: fdisk -l / bewerken partities: fdisk / grafisch: cfdisk
Format: mkfs.ext3 /dev/sd.. — tune2fs -m 1 /dev/sd.. to change percentage root to 1% (instead of standard 5%)
Check drive: /sbin/e2fsck /dev/sda1
Info drives: df (df -h : shows everything in a more readable format)

File permissions

Change owner: sudo chown [username] [filename]
Change group: sudo chgrp [groupname] [filename]
Change permissions: sudo chmod xxx [filename]

User management

Add users: adduser [username]
Add user to sudoers: sudo adduser [username] admin
Check groups of a user: groups [username]
List all users and last time they logged in: lastlog

Networking

IP configuration: ifconfig
Mount: sudo mount 192.168.1.11:/home/peter/data /home/peter/Documenten
mount -a: mount all mounts in the /etc/fstab file
showmount -e 192.168.1.1

Services

Monitor services: ps -aux
Restart services:
Network: sudo /etc/init.d/networking restart
NFS server: sudo /etc/init.d/nfs-kernel-server restart

Power management

boot: poweroff, reboot, logout

spindown: hdparm -y /dev/sdb
check status: hdparm -C
set standbye time: hdparm -S 240
time: 20 min -> 240; 5 min -> 60
advanced power management: hdparm -B

Making ISO images

DVD: dd if=/dev/dvd of=dvd.iso
CD: dd if=/dev/cdrom of=cd.iso
CD SCSI: dd if=/dev/scd0 of=cd.iso
Remark: the cd/dvd shouldn't be mounted
dd = bitstream duplication

To mount an ISO image: use gmount-iso (install from software centrum)

Varia

Get version of kernel: uname -r
Distribution: cat /etc/issue
Update: apt-get upgrade
Upgrade to a new version: apt-get dist-upgrade
Search packages: apt-cache search

Setting files

Network: /etc/network/interfaces
Mount: /etc/fstab
NFS server: /etc/exports
NFS client: /etc/fstab
Display: /etc/X11
hdparm: /etc/hdparm.conf (/dev/sdb {spindown_time = 240})
Sources: /etc/apt/sources.list

Scripting

Start script with: #!/bin/bash
Execute with: ./script.sh or sh script.sh

http://www.freeos.com/guides/lsst/

Synchronization with rsync

rsync options source destination
'Normal' command:
rsync -avz /home/peter/Downloads/ /home/peter/server/Downloads
Options:
a: archive: preserves attributes, permissions, ownerships…
v: verbose: increases the amount of information you are given during the transfer. By default, rsync works silently.
z: compress: reduces the amount of data being transmitted
Also mind the trailing / of the client. If it would not be there, a directory Downloads will be made on the server side.

If you want deleted files also to be deleted on the server, use the — delete option.

If you want to compare directories:
rsync -nrv /home/peter/Documenten/Projects/ /home/peter/server/Documenten/Projects
n: dry-run: perform a trial run that doesn't make any changes (and produces mostly the same output as a real run)
r: recursive: strange that it has to be used here

http://www.samba.org/ftp/rsync/rsync.html

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License