Skip to main content

Some SysAdmin Stuff

I'm going to start posting sysadmin-type things on this blog. I haven't done much writing other than technical recently. Posts here will focus on shorter snippets of information that I recently found out and want to pass along (mainly so I remember them myself).

Using @reboot in crontab -e

I recently discovered that the time interval @reboot can be used to start something upon server boot up. An example of this might be some script that you run continuously but that isn't set in /etc/init.d as a service to start on reboot (chkconfig service on). How it would be used is the following:

@reboot command

Let's say I have a script installed onto my machine to log every minute for the load and other processes. It won't restart on server reboot, so I could do the following for it in crontab -e (/var/spool/cron/root):

@reboot nohup ~/pathtoscript &

Grabbing the top level listing of permissions and ownership for a folder

Normally, I'd been using the following for a folder when I only wanted the top-level of the folder:

ls -lh /pathtofolder

This would show the full contents of the folder, which I didn't want. A better method would have been to use the -d flag:

ls -ld /pathtofolder

To see the difference, here's the returns for /home/admin on my test machine:

[root@itchy:/] # ls -lh /home/admin
total 360K
-rw-r--r-- 1 root root 2.8K Oct 28 2009 AccessIds.pm
lrwxrwxrwx 1 admin admin 31 Feb 28 2009 access-logs -> /usr/local/apache/domlogs/admin
drwxr-xr-x 4 admin admin 4.0K May 17 18:01 cpanel3-skel
-rw-r----- 1 admin admin 1 Oct 18 2009 cpbackup-exclude.conf
-rw-r--r-- 1 root root 433 Sep 22 2009 database.yml
drwxr-x--- 6 admin mail 4.0K Jan 28 15:27 etc
drwxrw-rw- 2 admin admin 4.0K Oct 29 2009 happytime
drwxrwx--- 12 admin admin 4.0K May 19 21:15 mail
-rw-r--r-- 1 root root 95K Jan 4 2010 mmangum.txt
-rw-r--r-- 1 dani dani 154K Apr 23 19:27 mysqluser.sql
drwxr-xr-x 2 admin admin 4.0K Jul 5 11:19 perl
-rw-r--r-- 1 admin admin 39K Jul 11 09:52 php.ini
drwxr-xr-x 3 admin admin 4.0K Aug 27 2009 public_ftp
drwxr-x--- 9 admin nobody 4.0K Jul 23 11:16 public_html
-rw-r--r-- 1 root root 13K Oct 28 2009 SafetyBits.pm
drwxr-xr-x 7 admin admin 4.0K Jun 24 18:53 tmp
lrwxrwxrwx 1 admin admin 11 Feb 28 2009 www -> public_html


[root@itchy:/] # ls -ld /home/admin
drwx--x--x 24 admin admin 4096 Jul 11 09:52 /home/admin


This is especially helpful if you want to drill down into folders to see just that folder's set permissions and ownership for any non-working service (like email). Here's an example to see /home/admin/etc/lunaradmin for the machine for each level:

[root@itchy:/] # ls -ld /home/admin /home/admin/etc /home/admin/etc/lunaradmin.com && ls -lah /home/admin/etc/lunaradmin.com/
drwx--x--x 24 admin admin 4096 Jul 11 09:52 /home/admin
drwxr-x--- 6 admin mail 4096 Jan 28 15:27 /home/admin/etc
drwxr-x--- 5 admin mail 4096 Jul 9 12:50 /home/admin/etc/lunaradmin.com
total 44K
drwxr-x--- 5 admin mail 4.0K Jul 9 12:50 .
drwxr-x--- 6 admin mail 4.0K Jan 28 15:27 ..
drwx--x--x 4 admin admin 4.0K Apr 10 15:52 admin
drwx--x--x 3 admin admin 4.0K Apr 10 15:52 cpacct
-rw-r--r-- 1 admin mail 152 Feb 24 13:23 passwd
-rw-r--r-- 1 admin admin 1.9K Feb 24 13:23 passwd,v
drwxr-x--- 2 admin mail 4.0K Feb 24 13:24 @pwcache
-rw-r--r-- 1 admin admin 33 Feb 24 13:23 quota
-rw-r--r-- 1 admin admin 387 Feb 24 13:23 quota,v
-rw-r----- 1 admin mail 107 Apr 10 16:00 shadow
-rw-r----- 1 admin admin 2.0K Feb 24 13:23 shadow,v


This allows you in one command to get all the necessary permissions in order to troubleshoot if there's something wrong for any of the levels leading into that folder for that domain's passwd file that handles the email user authentication for the domain.

Comments

Popular posts from this blog

The Journey’s End

  old and new, I’m here waiting for you over the hills and under the sun waiting for you as life has begun waiting for you as long as we’ll be waiting for you as you waited for me again we go together my friend through these woods as deep as our sorrows we’ll travel this way into each day through mountains and glens til tomorrow gilded and golden, sapling in green dusty and dark, light with a spark colors abound throughout our journey filling our hearts at all we’ve seen making us age at every stage we’ve dreamed all of life's majesty in the oceans and ponds and what lies beyond footsteps echoing on the hard ground voices fading out til they have no sound we arrive here where we started before each of us the same yet now we've changed one of us lives and cries and cries the other lies down in this cold ground and closes her eyes dusty and dark, light with a spark we’ll travel this way into each day through mountains and glens til tomorrow

The Fourth Riddle

  The Fourth Riddle I’m a whisper on the wind A thought held deep within Imprinted on your bones I won’t ever let you go I know your name I don’t forget anything By design, I hide The truth from sight Hush, shush Don’t rush They don’t know yet Try to keep me quiet Be silent They might buy it I’m embedded in your mind Entrenched inside How do you sleep each night? Worried they’re nearby This train is a one way trip But did you want a ticket? Oh, you can’t get off Until the end of the line Hush, shush Don’t rush They don’t know yet Try to keep me quiet Be silent They might buy it Hush, shush Don’t rush They don’t know yet Try to keep me quiet Be silent You can still deny it You are a prisoner of mine A prisoner in your mind I won’t ever let you go I control everything I’ll follow you to the grave Shhh Don’t talk

Moonlight Kite

I run with the kite in the field All the stars shining brightly The clear, moon-filled sky's expanse stretches wide String trailing behind me The kite lifts as I tug and pull A sharp jerk, I don't let it go Now, it's soaring high I let out more cord as it sails Above the ground, a sky ship Colorful in day, by night delicate Muted greys swerve and dip Yellow tails flutter from the bow As I slowly release more rope How far can it fly? Morning star on the horizon Near where the sun will be rising Dawn will soon arrive I remove small silver scissors Which glint in the twilight Setting the spool of coil onto the ground I look at the kite Kneeling down on my knees I snip the rope and release "Lord, send my prayers to him please" The kite, now free, rushes away My letter tied up with it sways With all of my hopes Every single word I could say I lay my head down on cool grass To find peace at last