..:::.. .:..::..:.. :...::...
     
  DoppelGanger  
     

Random Stuff

Mounting Hardrives

mounts harddrive NTFS
mount -t ntfs /dev/hda1 /mnt/windows -o umask=000,users,rw

unmount mounted harddrive
umount /mnt/windows

Utilities

traceroute
/usr/sbin/traceroute
-m10 max 10 hops -w2 wait 2 seconds

ping -c5 -i2 IPADDRESS
5 pings interval 2 seconds

Nmap Scans
nmap -sS -sV -O -v -D www.aol.com,ads.web.aol.com,ads.aol.com

DD command
dd output_file or dd if=input_file of=output_file
ex. dd if=/dev/fd0 of=/tmp/floppy.image from 3.5 to image
dd bs=2x80x18b < /tmp/floppy.image > /dev/fd0 from image to 3.5

Copying a CD to a File on your Filesystem
dd if=/dev/cdrom of=image.iso
cat /dev/cdrom >image.iso

Create an Image from a floppy
dd if=/dev/fd0 of=fileforshadows.img

Creating an ISO Image
mkisofs -RJ -o image.iso /burndirectory/
mkisofs -J -o image.iso /burndirectory

Commands

rmdir removes empty directories

rm removes files and directories
-f no prompts -r all files in directories
rm -f -r directory name

mv renames or moves files

cp copies files

cat view contents of file

less same as cat

ps -A shows all running processes

uptime This command displays a one line summary showing.

d This command displays a one line summary for the current user listing

free This command displays statistics on memory usage. The values represent KB's

w user info

df This command displays information for each file system.

env This command lists all shell (environment) variables and their contents for the current user.

top This command display a full screen of information of the top processes. It will update automatically until the program is stopped. To stop the display, enter q.

procinfo procinfo gathers some system data from the /proc directory and prints it formatted on the screen.

lspci or lspci -vvv view pci data for hardware

nice/ renice changes cpu throtlleing aka # of how a command is processed so it doesn't get all the priority of cpu

Disk Usage Check
du -k -h -s (directory)
du -k -h

File Permissions

chmod option name
Numeric Code Permissions
700 User: read, write, execute
Group: none
Other: none

755 User: read, write, execute
Group: read, execute
Other: read,execute

777 User: read, write, execute
Group: read,write,execute
Other: read,write,execute

707 User: read, write, execute
Group: none
Other: read, write, execute

change owner
chown newowneroffile nameoffile

change group
chgrp newgroup nameoffile

-rw------- (600) -- Only the user has read and write permissions.
-rw-r--r-- (644) -- Only user has read and write permissions; the group and others can read only.
-rwx------ (700) -- Only the user has read, write and execute permissions.
-rwxr-xr-x (755) -- The user has read, write and execute permissions; the group and others can only read and execute.
-rwx--x--x (711) -- The user has read, write and execute permissions; the group and others can only execute.
-rw-rw-rw- (666) -- Everyone can read and write to the file. Bad idea.
-rwxrwxrwx (777) -- Everyone can read, write and execute. Another bad idea.

Here are a couple common settings for directories:

drwx------ (700) -- Only the user can read, write in this directory.
drwxr-xr-x (755) -- Everyone can read the directory, but its contents can only be changed by the user.

Each permission setting can be represented by a numerical value:

r = 4
w = 2
x = 1
- = 0

When these values are added together, the total is used to set specific permissions - more specific than changing permissions with the alphabetical "shorthand."
rw-rw-rw- (666) rw= 4+2= 6, Rember the first bit is user, second group, third other

APT

apt-get update -- retrieves the latest list of software and updates available through apt-get. You should run this command before using other apt-get commands (you must run this at least once).
apt-get upgrade -- performs an upgrade for all obsolete software on your system.
apt-get install packagename -- installs software on your system. The package is the name of the RPM (see following table).
apt-get -- displays other apt-get options
apt-get dist-upgrade performs upgrade of entire system

Remove Kernels RPM

To remove old entries in the boot menu, simply uninstall the old kernel packages. That will get rid of the boot menu entries automatically, too.
Example (user "root" at command-line):
$ uname -r
$ rpm -qa | grep kernel
[b]# rpm --query --all 'kernel*' or rpm --query --all kernel
[color="green"]kernel-2.4.20-20.9[/color]
[color="red"]kernel-2.4.20-19.9[/color]
kernel-utils-2.4-8.29
kernel-doc-2.4.20-20.9
kernel-source-2.4.20-20.9
# rpm --erase [color="red"]kernel-2.4.20-19.9[/color]
[/b]

Mandrake kernels

Open a terminal as root and update your urpmi sources:
# urpmi.update -a
Read the advisory so you know what kernel version to install; for instance if the filename is kernel-2.4.19.24mdk-1-1mdk.i586.rpm you will want to execute:
# urpmi kernel-2.4.19.24mdk
or
# rpm -e kernel-2.4.8-26mdk

GRUB BOOTLOADER

title debtest
kernel (hd1,0)/boot/vmlinuz root=/dev/hdb4
initrd (hd1,0)/boot/initrd-2.4.22-10mdk.img

Grub Boot Floppy

Create a filesystem in your floppy disk (e.g. mke2fs /dev/fd0).
Mount the floppy on somewhere, say, /mnt.
Copy the GRUB images to the directory /mnt/boot/grub. Only stage1,
stage2 and menu.lst are necessary. You may not copy *stage1_5.
Unmount the floppy.
Run the following commands (note that the executable grub may reside in a different directory in your system, for example, /usr/sbin):
/sbin/grub --batch --device-map=/dev/null <device (fd0) /dev/fd0
root (fd0)
setup (fd0)
quit
EOF

How to Make A Grub Boot Screen

picture file 14bit color resolution saved as *.xpm then compressed to *,xpm.gz
1. xpm.gz file type
2. 640x480
3. 14 colors only
1. Gzip your xpm file and put it into your /boot/GRUB directory (or to any directory of a /dev/hda1 partition). (do: `gzip myfile.xpm`)
Using the gimp: Image > Mode > Indexed change colors to 14 and check "no color dithering to prevent guessing of colors.

Scsi Emulation for grub add the following lines
hdd=ide-scsi after kernel location specs

Grub Reboot In case kernel is bad after recomplie edit grub.conf

default saved # This is important!!!
timeout 10
fallback 1 # This is important!!!

title A
root (hd1,0)
kernel /kernel-2.6.7
savedefault fallback # This is important!!!

title B
root (hd2,0)
kernel /kernel-2.6.5
savedefault

Now set grub to boot off the new kernel next boot
#grub-set-default 0

System HACKS

Modules
etc/modules.conf (stores all your loadable modules uncomment for desired one)
/etc/rc.d/rc.modules
/etc/modprobe.conf
/etc/modules.autoload.d/kernelversion
modprobe (module name) start module immediately after adding it
modules-update updates afer commenting mondules.conf
rmmod (module name) removes module

/etc/inittab
change id:5:initdefault: to id:3 to disable gdm. xdm ie: X gui logon

etc/fstab mounts for file systems

TCP Wrappers

etc/hosts.deny
ALL:PARANOID
ALL:ALL

etc/hosts.allow
ALL:ALL:DENY
sshd : ALL : allow

To Allow normal users to be able to shutdown your pc:
chmod a+s /sbin/shutdown

X

etc/X11/
xf86config x86config-4 or XF86Config xorg.conf x server graphics settings

X11 fonts

/usr/X11R86/lib/X11/fonts or /usr/share/fonts

Configure X11

xf86config xf86cfg X -configure xfree86 -configure
xorgconfig xorgcfg
.xinitrc put (exec Xwindow) so you can just type startx program start on x program &
example: exec fluxbox This must be place as the last execute command

To Chose what Windows Manager You Use Type:

xwmconfig

Run 2 X windows

By default X uses the display :0
% startx
To open a second display, use another number f7 and f12
startx -- :1
Of course, to run X on screen 2, you'd use the command startx -- :2, and so on.

Do the following below by editing your X config file in /etc/X11

Shutting down Monitor with X make sure acpi is in the kernel

add Option "DPMS" to the Monitor Section and also Section Device
add Option "OffTime" "20" to Server Layout
test with xset dpms force off or standby or suspend

Increase Font Size using different dpi values

Place settings in monitor section
DisplaySize 280 210 (320x240) also looks good the lower the number the larger the fonts 4 to 3 ratio 70x4 70x3
320x240 for 1024x768 and 1280x1024
xrandr -s display size changes resolution
Xrandr another way to alter X resolutions

Taking Screenshots from Command Line

import -window root -pause 2 screenshot.jpg

Stop Nvidia Spash Screen

Put in your X config file located in /etc/X11/
Section "Device"
Identifier "geforce"
Driver "nvidia"
Option "NoLogo" "1" # add this line to remove the Nvidia boot logo

Enable 3rd Mouse wheel Scroll

Put in your X config file located in /etc/X11/
Section "InputDevice"
Identifier "Mouse1"
Driver "mouse"
Option "Protocol" "IMPS/2"
Option "Device" "/dev/mouse"
Option "ZAxisMapping" "4 5" # adding this line worked

Move mouse with keyboard

Hit shift and numlock key, Then use num lock keypad to move mouse. Hit shift and numlock key to disable

Xorg Transparency

put in etc/X11/xorg.conf
Section "Extensions"
Option "Composite" "Enable"
Option "RENDER" "Enable"
EndSection

Then run the following command: xcompmgr -c &
Then transset .2
(note: 0 = fully see through, 1 = no transparency)

Securing X

cd /usr/X11R6/bin
edit startx
Change defaultserverargs="" to defaultserverargs="-nolisten tcp"

Terminals

Cntrol D exits terminal
CTRL F1 THRU F7 Switch dispays for multitask with virtual consoles
CTRL C cancels a command
CTRL Z stops a command
q exits all console based commands ex less

Editors

VI editor for files
:w will save (write) the file
:q will exit the editor.
:q! forces the exit when you want to quit a file containing unsaved changes.
:wq will save and exit
:w newfile will save the text to newfile.
:wq! overrides read-only permission (if you have the permission to override permissions, for instance when you are using the root account.
yy will copy a block of text.
n p will paste it n times.
:recover will recover a file after an unexpected interruption.
dd erase line
shift d erase last typed section
i insert

Emacs

Ctrl X C close
Ctrl X f open file
ctrl X S save files

Services

All servies are stored there /etc/init.d/
/# /etc/init.d/httpd start starts service
/# /etc/init.d/httpd stop stops service
/# /etc/init.d/httpd restart restarts service
In Slackware the services are in /etc/rc.d ie /etc/rc.d/rc.httpd start/stop/restart

Security

To have your terminal cleared, add clear to your ~/.bash_logout script:
$ echo clear >> ~/.bash_logout

If you want this to happen automatically when you add a new user, do the same for the /etc/skel/.bash_logout:
# echo clear >> /etc/skel/.bash_logout

If you want root to be able to log on through the serial console, add tts/0 to /etc/securetty:
# echo "tts/0" >> /etc/securetty

Clear Bash History

put this in ~/.bashrc
if [ -f ~/.bash_history ]; then
rm ~/.bash_history
fi

Kernel Security /etc/sysctl

Change kernel parameters and variables on the fly you need CONFIG_SYSCTL defined in your kernel. This is default in a standard 2.4 kernel.

Drop ping packets
# /bin/echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_all
Ignore broadcast pings
# /bin/echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
Disable source routed packets
# /bin/echo "0" > /proc/sys/net/ipv4/conf/all/accept_source_route
Disable redirect acceptance
# /bin/echo "0" > /proc/sys/net/ipv4/conf/all/accept_redirects
Protect against bad error messages
# /bin/echo "1" > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses
Enable reverse path filtering
# for i in /proc/sys/net/ipv4/conf/*; do /bin/echo "1" > $i/rp_filter done
Log all spoofed, source routed and redirect packets
# /bin/echo "1" > /proc/sys/net/ipv4/conf/all/log_martians
Deactivate IP forwarding
# /bin/echo "0" > /proc/sys/net/ipv4/ip_forward

Limiting User Processes

edit /etc/limits and add:
* U 150
edit /etc/security/limits.conf and add:
@users soft nproc 100
@users hard nproc 150
* hard core 0

Openssl encryption of files

Encrypting with password
openssl enc -aes-256-cbc -salt -in password.txt -out password.txt.enc
openssl enc -d -aes-256-cbc -in password.txt.enc -out password.txt
or
openssl des3 -salt -in file.txt -out file.des3
openssl des3 -d -salt -in file.des3 -out file.txt -k mypassword

Generating random passwords
openssl passwd password
openssl passwd -1 -salt xxxxx password
openssl passwd -apr1 -salt xxxxxxxx password

Gnupg

Generating keys
gpg --gen-key

Encrypting/Decrypting
gpg -c to encrypt with password
gpg -d decrypt

Disable terminal beep

# setterm -blength 0
If you would like to turn off the console beeps on boot you need to put this command in /etc/conf.d/local.start. However, this only disables beeps for the current terminal. To disable beeps for other terminals, pipe the command output to the target terminal, like this:
Using setterm (bis)
# setterm -blength 0 >/dev/vc/1

Decompress Files

For: *.tar.gz, *.tgz, *.z, *.Z, *.taz, *.tar.Z
tar -zxf filename.tgz
is the same as:

gunzip filename.tgz
tar -xf filename.tar

For: *.bz, *.bz2, *.tbz, *.tbz2, *.bzip2
tar -Itf filename.bz
is the same as:

bunzip filename.bz
tar -xf filename.bz

*.bz2
bunzip2 file name

*.gz
gunzip filename

Creates tar directory with name
tar xvf gaim-0.59.8.tar.gz -C new-directory

tar xvjf *.bz2
tar xvzf *.gz
tar xvf *.tar
unzip *.zip

Compressing Hardrive
tar -zcvpf name.tar.gz

Decompress Harddrive tar
tar -zxvpf name.tar.gz

To Unzip Multiple Tar.gz Files Type this code into a Console window:
for i in *.tar.gz; do tar xzvf $i; done

To Rename/move files
for n in *.dist; do mv $n `basename $n .dist`; done

DVD Playback linking drive obviously ln command

ln -sf /dev/hdc /dev/dvd
ln -s path/to link/to

Activating my rear speakers

installl alsaguimixer and raise bar for WAve Surround :-)

Filesystem checks

tune2fs -c and -C
fsck /dev/hdX
reiserfsck /dev/hdX
drives must not be mounted

OpenSSh

SSH logins
ssh -l username host change ssh damemon settings /etc/ssh might wanna change ssh port for security reasons

Creating ssh key
#/usr/bin/ssh-keygen -t dsa
This will add two files in your ~/.ssh/ directory called id_dsa and id_dsa.pub. The file called id_dsa is your private key and should be kept from other people than yourself. The other file id_dsa.pub is to be distributed to every server that you have access to. Add the key to the users home directory in ~/.ssh/authorized_keys and the user should be able to login.

SFTP Cl
For non standard ports use the -o option
sftp -oPort=23 hostname

Networking

To Rotate dns servers
put in /etc/resolv.conf
options rotate
options timeout 1

For Dhcp: To Prevent long wait for lease
iface_eth0="dhcp"
dhcpcd_eth0="-t 3"

IFConfig Quicke

ifconfig eth0 your_ip broadcast broadcastip netmask your_netmask up
route add default gw your_gateway
echo "nameserver your_nameserver" > /etc/resolv.conf

Standard Networking

ip: 192.168.0.2 broad: 192.168.0.255 mask: 255.255.255.0 Gateway: 192.168.0.1
nameserver: 195.130.130.5 195.130.130.133
How To ascertain broadcast ip: if ip is 192.168.1.20 then broadcast is 192.168.1.255

Kill programs that won't die

kill -s 9 PID
kill -HUP PID

Bash Keys

Alt+B // Go back one word
Alt+F // Go forth one word
Ctrl+K // Delete everything from the cursor to the end of the line
Ctrl+U // Delete everything from the cursor to the beginning of the line
Ctrl+Y // Paste deleted characters at the current position
Ctrl+H // Delete one character
Ctrl+L // Clean screen
Ctrl+P // Go to the previous history entry
Ctrl+N // Go to the next history entry

Fix Kde Sound Server problems

remove -F -S keys to arts
~/.kde/share/config/kcmartsrc

CD Burning

cdrecord -v gracetime=2 dev=/dev/hdd speed=40 -dao driveropts=burnfree -eject -data foo.iso
normalize -m
for i in *.mp3 ; do lame --decode $i $i.wav ; done

 
 
Mounting
Utilities
CHMOD
Debian APT
RPM Kernels
Grub Bootloader
System Hacks
X
Terminal/VC
VI/Emacs
Services
Security
Tar
DVD Sysmlink
Rear Speaker
File Sys Check
OpenSSH
Networking
Kill
Bash Keys
KDE Sound Fix
Cd Burning