1. History
2. Kernel
3. Network
4. Package Management
5. Patch
6. Process
7. Security
8. Tricks
Sometime, it can be useful recording what you are doing, so that you can see later what have you done.
1.1. Ttyrec
Records what do you do in a console.
Start recording:
ttyrec
Stop recording:
CTRL + D
Playing:
ttyplay ttyrecord
Additionally, you can save what have you done in a file:
ttyrec myFile
For playing:
ttyplay myFile
1.2. X11rec
Records graphical window.
Currently (Sarge) there is not a Debian package.
2.1. Compiling
To compile a kernel:
make-kpkg --append-to-version=-yourHostName --revision=yourRevisionNumber kernel_image modules_image
For example:
make-kpkg --append-to-version=-tux --revision=4 kernel_image modules_image
2.2. Getting version
To get the version of the current loaded kernel:
uname -a
3.1. Cloning disk over the network
If you have 2 PCs with the same hardware, for example host1 and host2, it's enough to install the system on host1. For host2, you can clone the harddisk content via network using netcat.
First, open an incoming connection on host2:
nc -l -p 9000 | dd of=/dev/hda
Then start the transfer from host1:
dd if=/dev/hda bs=128M | nc -w2 host2 9000
4.1. DEB on Debian and derived
4.1.1. Installing
From repository:
apt-get update
apt-get install package
From file:
dpkg -i package.deb
4.1.2. Removing
Without removing configuration files:
apt-get remove package
or
dpkg -r package
Removing configuration files:
apt-get --purge remove package
or
dpkg --purge package
4.1.3. Updating/upgrading
apt-get update
apt-get dist-ugprade
or
dpkg -i newpackage.deb
4.1.4. Checking if installed
dpkg --get-selections | grep package
4.1.5. Checking if available
apt-cache search package | less
4.1.6. Searching package providing a file
apt-file udpate
apt-file search myFile
4.1.7. Getting list of installed packages
dpkg --get-selections > packages.txt
4.1.8. Using list of installed packages
In this way, it is possible to install in one shot all the packages extracted with --get-selections:
dpkg --set-selections < packages.txt
apt-get dselect-ugprade
4.2. RPM on Red Hat and derived
4.2.1. Installing
rpm -i package.rpm
rpm -ivh package.rpm
4.2.2. Updating/upgrading
rpm -U package.rpm
rpm -Uvh package.rpm
4.2.3. Removing
rpm -e package.rpm
4.2.4. Checking if installed
rpm -V package.rpm
4.3. TGZ on Slackware and derived
4.3.1. Extracting archive
explodedpkg package.tgz
4.3.2. Installing package
installpkg package.tgz
4.3.3. Creating archive
makepkg package
4.3.4. Removing
removepkg package.tgz
4.3.5. Updating/upgrading
upgradepkg old_package [new_package]
4.4. From source
tar xvzf source.tar.gz
tar xvjf source.tar.bz2
cd source
./configure
make
su
make install
5.1. Applying
patch -p1 < yourPatch
6.1. Fuser
Get the process which is using a resource (e.g.: cdrom, mounted partition, ...)
fuser -v /cdrom
fuser -v /media/usbstick
7.1. Setuid
The setuid bit, also known as SUID, is a privilege bit that means a program is run with the privileges of its owner instead of who is calling it.
For example, setting the setuid bit to /bin/cat, all normal users will be able to read every file on the disk, independently of they are allowed or not!
To set the setuid bit:
chmod u+s yourFile
Don't abuse from this feature. It can make your system very unsafe!
7.1.1. Detail
There exist the following privileges.
Normal IDs
- UID: User ID
- GID: Group ID
Real IDs
- RUID: Real user ID
- RGID: Real group ID
Effective IDs
- EUID: Effective user ID
- EGID: Effective group ID
The normal IDs identify the univoque user/group identification number.
The reald IDs are used by the kernel to identify who has created the process.
The effective IDs are used by the kernel to identify wich user/group privileges must be used.
If the setuid bit is NOT set, the real IDs are the same as the effective IDs and are copied from the normal IDs .
If the setuid bit is set, the kernel copies the real IDs from the normal IDs and the effective IDs from the file owner.
In this way, it is possible to allow a normal user to do some operation normally restricted to the root only.
For example, setting the setuid bit to /bin/cat, each user can use this program to read files which normally they could not be read.
8.1. Splitting file
split -b mySize myFile
This creates:
xaa, xab, ...
To restore:
cat xa* > myFile.restored
8.1.1. Splitting backup
tar -cf - myDirectory | gzip --best | split --verbose -b800m
|