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

Be Someone

When I shut my eyes And hold them tight The colors flash In my head so bright A whirlwind swirls The ocean’s waves A tide that’s fierce The sun’s sharp rays I think of you too far away You’ll never be here where I live You’ll never see this place Never have the same experiences Can I be someone Will it be enough Can we stay this way Despite the distance away I might still be the one You love I might still be the one You love Each day unfolds Going through these motions Attempts to care To be sane and well Not in a self-made hell Tired and spent Cracked and dry Lines forming on my hands Around my eyes I think of you too far away You’ll never be here where I live You’ll never see this place Never have the same experiences Can I be someone Will it be enough Can we stay this way Despite the distance away I might still be the one You love I might still be the one You love Can you be someone Will you be enough Should we stay this way Too distant and far away Am I still the one You love Are y...