A common question : how to allow normal user to mount cdrom

Swap File — Good Option

# dd if=/dev/zero of=/swapfile bs=1024 count=100000
This will create file (swapfile) of size 100 MB (round)

# mkswap /swapfile

Now add this file to your swap pool
# swpaon /swpafile

Erase the Content of Disk Drive

Keeping Files in Sync Between Servers

Mounting an ISO Image as a Filesystem

How to Put a "Running Job" in the Background.

You’re running a job at the terminal prompt, and it’s taking
a very long time. You want to put the job in the backgroud.

“CTL – z” Temporarily suspends the job
$ jobs This will list all the jobs
$ bg %jobnumber (bg %1) To run in the background
$ fg %jobnumber To bring back in the foreground

Need to kill all jobs — say you’re using several suspended
emacs sessions and you just want everything to exit.

$ kill -9 `jobs -p`

The “jobs -p” gives the process number of each job, and the
kill -9 kills everything. Yes, sometimes “kill -9″ is excessive
and you should issue a “kill -15″ that allows jobs to clean-up.
However, for exacs session, I prefer “kill -9″ and haven’t had
a problem.

Sometimes you need to list the process id along with job
information. For instance, here’s process id with the listing.

$ jobs -pl

Note you can also renice a job, or give it lower priority.

$ nice -n +15 find . -ctime 2 -type f -exec ls {} \; > last48hours
$ bg

So above that was a ctl-z to suppend. Then, bg to run it in
the background. Now, if you want to change the priority lower
you just renice it, once you know the process id.

$ jobs -pl
[1]+ 29388 Running nice -n +15 find . -ctime 2 -exec ls -l {} \; >mout &

$ renice +30 -p 29388
29388: old priority 15, new priority 19

19 was the lowest priority for this job. You cannot increase
the priority unless you are root.

Sharing Directories Amoung Several Users

Several people are working on a project in “/home/share”
and they need to create documents and programs so that
others in the group can edit and execute these documents
as needed.

$ /usr/sbin/groupadd share
$ chown -R root.share /home/share
$ /usr/bin/gpasswd -a share
$ chmod 2775 /home/share

$ ls -ld /home/share
drwxrwsr-x 2 root share 4096 Nov 8 16:19 /home/share
^———- Note the s bit, which was set with the chmod 2775

$ cat /etc/group

… ^——- users are added to this group.

The user may need to login again to get access. Or, if the user is currently
logged in, they can run the following command:

$ su –

Note, the above step is recommended over “newgrp – share” since currently
newgrp in FC2,FC3, and FC4 gets access to the group but the umask is not
correctly formed.

As root you can test their account.

$ su – “You need to ‘-’ to pickup thier environment ‘$ su – chirico’ ”

Note: SUID, SGID, Sticky bit. Only the left most octet is examined, and “chmod 755″ is used
as an example of the full command. But, anything else could be used as well. Normally
you’d want executable permissions.

Octal digit Binary value Meaning Example usage
0 000 all cleared $ chmod 0755 or chmod 755
1 001 sticky $ chmod 1755
2 010 setgid $ chmod 2755
3 011 setgid, sticky $ chmod 3755
4 100 setuid $ chmod 4755
5 101 setuid, sticky $ chmod 5755
6 110 setuid, setgid $ chmod 6755
7 111 setuid, setgid, sticky $ chmod 7755

A few examples applied to a directory below. In the first example all users in the group can
add files to directory “dirA” and they can delete their own files. Users cannot delete other
user’s files.

Sticky bit:
$ chmod 1770 dirA

Below files created within the directory have the group ID of the directory, rather than that
of the default group setting for the user who created the file.

Set group ID bit:
$ chmod 2755 dirB

Setting up 2 IP address on "One" NIC

Backing Up & Restoring MySQL database

The easy way to make a backup of a database is to use MySQL Backup. MySQL Backup is a Perl script that uses mysqldump, tar, and gzip. The documentation is in the script, and it’s simple to use. Starting at around line 104, comment out the three lines referencing CGI commands. These are for running backups from a Web browser, which is not a secure way to run the backups. The easiest thing to do is set everything up in the script, then run it automatically from a cron job. Anywhere a program or file is named, be sure to use the full absolute path name.

You’ll have the option to backup all tables, or to select certain ones. The backups are stored locally by default, and can be uploaded via FTP to another location. There is even an option to email the backups to whatever lucky soul is elected to receive them.

This cron job runs the script every midnight:

# crontab -e
0 0 * * * /usr/sbin/scripts/mysql_backup

Restoring a database from backup is done by redirecting the contents of the backup file to the original location:

# mysql -u nikesh -p [password] My_DB

How to Use MD5


Get every new post delivered to your Inbox.