Whoever Resembles a People is One of Them. He is not one of us who resembles other than us,
nor who resembles the Jews nor the Christians.(jami-at-tirmidhi-vol-5-ahadith-2695)
O you who believe (who wish to reach ALLAH C.C. before death)! Do not take my and
your enemies for friends!
And although they have denied what has come to you
from the Truth, you still love them (treating them as your friends).
If you go forth to struggle hard in My Way, seeking My Pleasure, (then why) you manifest
love to them and share with them your secrets.
And I know what you conceal and what you manifest. And whoever of you does that, then he
indeed has gone astray from the right Way. 60/Al-Mumtahanah-1
They are driving out the Messenger and yourselves from your land because you
believe in ALLAH C.C., your Lord.
Recite (read and explain to others) that which has been revealed to you of the Book
and keep up the Prayer.
Surely the Prayer keeps away from Al-Fahsh (to do what ALLAH C.C. prohibits) and Al-Munkar
(to deny what ALLAH C.C. commands).
Whoever obeys me, obeys ALLAH C.C., and whoever disobeys me, disobeys ALLAH C.C.
Whoever obeys the ruler, obeys me, and whoever disobeys the ruler, disobeys me. " (Sahih)



HDD Operations

adding a hdd

fdisk /dev/sdx partition olusturma
mkfs.ext3 /dev/sdx ile ext3 formati atilir.
mount –t ext3 /dev/sdx /disk1 /dev/sdx /disk1 folderina mount edilir.
fdisk –l kontrol edilir.
mount kontrol edilir.

NTFS Mount operations

cat /proc/ filesystems -- ntfs should be in this output, if it's absent then there could be some problems
mount /dev/sdb1 /media/sdb -t ntfs -rw -o umask=0222 (mounts to /media/sdb on disk sdb1)
umount sdb -- to cancel the mount

If the ntfs-3g entry in fstab has been loaded:

/dev/sdb1 /media/sdb ntfs-3g dmask=022,fmask=133,noauto,locale=hu_HU.UTF-8,user 0 0

Low Level Format

cat /dev/zero /dev/hdX -- alternatively, dd if=/dev/zero of=/dev/hdX

To view all of hdds in the system

sfdisk --list

To only view the directories

ls -l | grep "^d"

Copying from a faulty partition (hda) to a healthy partition (hdb)

dd if=/dev/hda of=/dev/hdb bs=512 conv=noerror,sync

To view the amount of storage used by the home folder

du -s /home/* | sort -rn

Viewing the disk capacity in terms of GB (Gigabytes)

df -k | grep -vE ' kbytes | : | swap ' | awk ' { t+=$2 } END { print "Total GB: ", t/1000000 } '

A dangerous command that could delete the entire system if entered as a root user

rm -rf /

Checking whether the disk is stable

dd if=/dev/hda of=/dev/null bs=64K

A dangerous command that could delete the entire system if entered as a root user

1- rm -rf /


To format to an ext2 filesystem

1- mkfs.ext2 /dev/sdx
2- mkfs.ext3 /dev/sdx

Assigning newly added disks to the dbms

echo "- - -" > /sys/class/scsi_host/host0/scan
echo "- - -" > /sys/class/scsi_host/host1/scan
echo "- - -" > /sys/class/scsi_host/host2/scan
echo "- - -" > /sys/class/scsi_host/host3/scan

Changing and checking the hostname

uname -n
hostname -a
hostname -s
hostname -d
hostname -f

/etc/hosts - if the IP address has been assigned using DHCP mybox.mydomain.com localhost.localdomain localhost mybox

For Static IP addresses localhost.localdomain localhost mybox.mydomain.com mybox

Output using the hostname command

hostname machinename.fieldname.com

Checking the the contents of the /etc/sysconfig/network folder when assigned a static IP address

cd /etc/sysconfig
vi network
vi /etc/hosts
service network restart


netstat -rn
route add -net netmask gw

Defining/declaring a route

route add -net netmask gw 10.30.0.
route add -net netmask gw
route add -net netmask dev eth0
default route delete
route del default gw
default route add
route add default gw

Adding and deleting a route

route add -net gw
route del -net gw

Adding and deleting a specific host

route add -host gw
route del -host gw

The routes in /etc/sysconfig/static-routes don't change

eth1 net netmask gw
eth1 net netmask gw


The IP command can be used to define a static route, the routes can be viewed using ip route show dev eth1 proto kernel scope link src dev eth0 proto kernel scope link src
default via dev eth0
adding a static route
ip route add {NETWORK} via {IP} dev {DEVICE}

Example of transiting to the network using as a gateway

ip route add via dev eth1

As an alternative

route add -net netmask gw dev eth1

By default these entered routes are deleted after a restart, if wanting to make them permanent they should be saved to thet static-routes folder (this path is different on Linux systems) the routes in the bulletin server
ip route add via dev eth0
ip route add via dev eth0

On the Fedora distro, in the /etc/sysconfig/network-scripts/ directory create a file called route and enter the route nodes (hops) in the following format via

Opening and Closing the IPTABLE Ports
To open:

iptables -A INPUT -p tcp --dport -j ACCEPT
iptables -A INPUT -p udp --dport -j ACCEPT

To close:

To close incoming requests

iptables -A INPUT -p tcp --dport -j REJECT
iptables -A INPUT -p udp --dport -j REJECT

To close outgoing requests

iptables -A OUTPUT -p tcp --dport -j REJECT

To ignore all arriving ping queries


To list all the active ports:

To list all the active ports:
To list all the active ports:

Using tcpdump

tcpdump -w /tcpdump1.log src and tcp port 22
tcpdump src and tcp port 22
tcpdump src and tcp port 161
/etc/rc.d/init.d/xinetd restart

To see who has connected using Port 80, the lsof (list open files package) needs to be installed

lsof -i tcp:80

Use the following command to view the systems Internet IP address

ifconfig ppp0 | grep inet | cut -c 11-34

The following command to view the ethernet card's IP address

ifconfig eth0 | grep inet | cut -c 11-34

Dumping the exchanges between the SNMP agent and SNMP manager using a network sniffer, like tcpdump, into another window.

tcpdump -vv -i lo

adduser -d /home/bdd bdd
userdel omer -- Deleting the user from user Burak's system and protecting the home folder
userdel -r omer -- Deleting the user from user Burak's system as well as deleting the home folder


Prior to the delete operation - the following line can be used to delete the user's files "with a find and delete operation" that are outside of the home folder.

find -user burak -exec rm {} \;
groupadd electric

The groups program is useful in finding out which groups that a user belongs to and can be run as shown here:
To add omer to the ftp-users group

usermod -G ftp-users omer

$ groups omer
users, staff
A user logged onto a system can only work as a group member, in terms of privileges. When a user logs on to a system, by default they are categorized as a member of the main group.
The user can switch to an active group using the newgrp program.Example:
If Burak would like to switch from the users group to the staff group, this can be done using the following line:

$ newgrp staff

A user can query the user group they are currently connected with the id command, it can be used to view the user's id and other related information:
$ id
uid=500(burak) gid=550 groups=500,550
The root user can grant any user a new password without having to enter their user information:
# passwd burak

Whenever a user wants to run a program they can open a general purpose shell window and run the program under this shell.
For example a user using the Bash shell wanting to switch to csh (C shell) due to being more familiar with it can do so using the following command:

$ /bin/csh
-- For temporary csh use, when finished with the c shell
% exit


Use > or >> to write the output of the command to a file.
Example: Running the following code, while in a folder, creates a file that has the same name as the folder's processes. The contents of the file would be the output of the ps auxw command.
There wouldn't be any output onto the screen as the entire output would be written to the file.

1- $ ps auxw > processes

After logging on to the system, the shell automatically defines a folder's environmental variables.
The list of environmental variables can be output using the printenv command: $printenv
Auditing accesses to files and folders
The chown folder is useful for changing the folder's ownership. The following code can be used to change the ownership.

ls -l bsd.c
-rw-r--r-- 1 bdd staff 20911 Jan 22 01:21 bsd.c
chown burak bsd.c
-rw-r--r-- 1 burak staff 20911 Jan 22 01:21 bsd.c

chgrp can be used to change the group that a user is connected to. The following code can be used to achieve this.

# ls -l bsd.c
-rw-r--r-- 1 bdd staff 20911 Jan 22 01:21 bsd.c
# chgrp users bsd.c
-rw-r--r-- 1 bdd users 20911 Jan 22 01:21 bsd.c

* Using a chmod program to give a u+s privilege identifier before granting a program a SUID (set user ID) privilege.

# chmod u+s /bin/bash
-rwsr-xr-x 1 root root 512540 Aug 22 19:46 /bin/bash

In a way similar to SUID, it might be necessary to grant some programs temporary user group membership in order to run them.
An example of this is some software related to printer services requiring this.
Using the chmod program to grant a g+s privilege identifier before granting a SGID (set group ID) privilege.

chmod g+s /bin/bash

Defining a link.

ln /reports/january-sales.txt /best-sellers/2001-january.txt

The above code defines an alternative access route for a file using /reports/january-sales.txt, called /best-sellers/2001-january.txt.
After applying the above definition, even if one of these file names is deleted the file will remain accessible until the other filename has been deleted. However deletion of the last hard-link will result in the file being linked to also being deleted.
-rwxr-sr-x 1 root root 512540 Aug 22 19:46 /bin/bash
The following code defines a hard-link to a file named php.ps:

# ls -l
total 239
-rw-r--r-- 1 root root 242783 Dec 13 10:50 php.ps
# ln php.ps php-document.ps
# ls -l
total 478
-rw-r--r-- 2 root root 242783 Dec 13 10:50 php-document.ps
-rw-r--r-- 2 root root 242783 Dec 13 10:50 php.ps

Soft-links are a type of link file that can be defined by any system user and are easier to understand and manage. They also allow access to a present file through a variety of routes.
The difference between soft and hard links is: when a soft-link is deleted the original file remains and if the original file is deleted, the soft-link remains but doesn't point to anything.
A soft-link can be created by using the -s parameter as shown in first line of the following example:

$ ln -s /reports/january-sales.txt /best-sellers/2001-january.txt
$ rm /reports/january-sales.txt
$ cat /best-sellers/2001-ocak.txt
No Such File or Directory

The Linux operating system, also known as a distro, clock runs independently of the BIOS or hardware clock. Setting the system's (distro) clock according to the hardware's clock

hwclock -s or hwclock -- requires using one of the hctosys commands


Setting the system clock manually (user input)

date -s "2009-11-20 16:18"

Setting the hardware clock according to the distro's clock

hwclock --systohc

Setting the hardware clock manually (user input)

hwclock --set --date "13 Dec 2007 14:13"

To synchronize the hardware and the distro clock using crontab

* */10 * * * /sbin/hwclock -s > /dev/null

Coming soon

tar archives are a type of compressed file, similar to zip files.

tar czfv file_name.tgz directory_to_make_a_tar

SCP (secure copy) securely copyies files between a local and a remote system
The following code copies the contents of the local downloads folder to the machine with at IP to its /shared/programs folder:

scp -r /downloads root@

Recording audio

rec example.wav --type=wav

To view the libraries that a specific program uses

ldd 'which kmail'

Replacing all the .html files extensions with .txt extensions

for i in $(find . -name ' *.html ' ) ; do mv $i ${i/.html/.txt} ; done

To switch between XServers

Using CTRL+ALT+F7 and CTRL+ALT+F8 key combinations

When there are performance issues, the following code finds and closes (kills) long running processes using kill -9 process id.

Ps aux|grep qmailr |grep date

Fast creation of the snmpd.conf file at first use

snmpconf -g basic_setup

Searching folders identified by their paths (could be useful on mounted CDROMs or the NFS directory)

find / \(-path /cdrom -o -path /mnt/server \) -prune -o -name searched_file.txt -print

To delete a file using the find command and file extension

find /home -name *.avi -print -exec rm -rf {} \;

To view only the folders or files that are linked to

1ls -l | grep ^d only folders
ls -l | grep ^l only links

Actively following or tailing recorded logs

tail -f /var/log/messages

Killing all parent and child processes that were started by a logged on user

pkill -u User_name

Activating the DMA mode of a CD-Rom (useful in situations when frames are skipped or with similar processes during film playback)

hdparm -d1 /dev/hdX

To place the monitor in Standby mode

xset dpms force off

To download a specific folder from the Internet

wget -r -np http://specific_folder/
cp /usr/share/zoneinfo/Europe/Istanbul /etc/localtime

to: user@domain.com

field # meaning allowed values
1 minute 0-59
2 hour 0-23
3 day of month 1-31
4 month 1-12 (or names, see below)
5 day of week 0-7 (0 or 7 is Sun, or use names)

At 03:00 (morning) daily from Monday to Friday

0 3 * * Sat /home/oracle/Batches/RmanFULLStarter.sh

Only on Mondays

* * * * 1 /usr/local/program -- options

Crontab related examples
# Prints out the ram to /tmp/ram every hour

0 * * * * /usr/bin/free > /tmp/ram
# To run a script at 2:00, 3:00, 4:00 (writing it as 2-4 indicates the intervals)
1- 0 2-4 * * * /root/test.sh


# Running a script at 06:30 (morning) on the 1st and 15th of every month

1- 30 6 1,15 * * /root/backup.sh

# To run a mrtg script every 5 mins

*/5 * * * * /root/mrtg.sh

# To run disk.sh every Saturday at 11

* 11 * * Sat /root/disk.sh

# To run a script every 2 hours

* */2 * * * /root/test.sh

Installing Tiger VNC

yum install tigervnc-server


Entering users in to the config file to allow remote access

vi /etc/sysconfig/vncservers
VNCSERVERARGS[2]="-geometry 1024x768 -depth 16"
VNCSERVERS="1:oracle 2:oinstall"
VNCSERVERARGS[1]="-geometry 800x600"
VNCSERVERARGS[2]="-geometry 800x600"

Setting a password (to allow a user to connect remotely)


To configure the vnc service to connect automatically when the system starts

chkconfig vncserver on
service vncserver restart

To end any vnc session

vncserver -kill :1

Granting permission in the iptables

A INPUT -p tcp -m state --state NEW -m tcp --dport 6001 -j ACCEPT
A INPUT -p tcp -m state --state NEW -m tcp --dport 5901 -j ACCEPT

Configuring a Local Gateway Server
Change the /etc/sysctl.conf file by using " net.ipv4.ip_forward=1 " and activate the changes with #sysctl -p
Internet NIC ---> eth0 (the ID of the Internet connected network adapter)

IP =
netmask =
GateWay =


Local NIC---> vboxnet0

IP =
netmask =
GateWay = leave empty


iptables rules

ptables -A FORWARD -o eth0 -i vboxnet0 -s -m conntrack --ctstate NEW -j ACCEPT
iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -F POSTROUTING
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

Client Machine Settings
Note: The gateway's IP address is what will be used by clients wanting to connect to the Internet using the gateway server.

ip = 10.0.2.x
netmask =
GateWay =
/etc/resolv.conf should have a valid dns entered.
No response with ping google.com
A response with ping or another public IP address indicates that there's a problem with the DNS or that the dns string is missing from the /etc/nsswitch.conf file.

Create a partition using fdisk /dev/sdb.
First check to see if "dm_crypt" has been installed, install if it hasn't.

lsmod |grep dm_crypt
modprobe dm_crypt


If it hasn't been loaded

yum install cryptsetup-luks


cryptsetup luksFormat /dev/sdb1 # Enter YES (uppercase) when prompted and enter the passphrase
cryptsetup luksOpen /dev/sdb1 encdisk # enter a name for the encdisk
mkfs.ext4 /dev/mapper/encdisk


mkdir /data
mount /dev/mapper/encdisk /data/


To check:

df -h

The line to be entered into /etc/fstab

/dev/mapper/encdisk /data ext4 defaults 0 0

To check:

umount /data
mount -a

Line to be entered into /etc/crypttab

encdisk /dev/sdb1

When the OS loads it prompts for a password, for it to prompt for a password it needs a keyfile, which can be created as shown here:

touch /etc/keyfile
chmod 0400 /etc/keyfile
cryptsetup luksAddKey /dev/mapper/VG_sda1-LV00 /etc/keyfile


cryptsetup luksAddKey /dev/mapper/VG_sda1-LV00 /etc/keyfile

Copyright © 2015 Sysdba All Rights Reserved Web Designer