As a System Administrator, there are many things that you need to know; you can’t just point and click your way around problems. While the number of skills is vast, I’ve narrowed them down to my list of the top 5 practices of a good UNIX System Administrator.
Tag Archives: tips and tricks
How to Use wget for Recursive get Without Traversing the Parent Directory
When grabbing files with wget, it is useful to sometimes not traverse parent directories. For example, say I want to download everything under http://www.example.com/my/home recursively, but not traverse upwards into parent directories. You can add the –no-parent option for this.
|
1 |
$ wget -r --no-parent http://www.example.com/my/home |
How to Change the UID of a Running Process
Recent versions of Solaris come with a suite of tools known as the “/proc” tools, which list and/or modify process information in the kernel-maintained /proc filesystem. One of these tools, pcred, can be used to change (among other things) the UID of a running process, e.g.:
|
1 2 3 4 5 6 7 |
# ps -ef | grep sleep root 25853 22210 0 09:55:53 pts/10 0:00 grep sleep kevin 24088 24081 0 09:50:53 pts/11 0:00 sleep 10000000 # pcred -u 123 24088 # ps -ef | grep sleep mrbig 24088 24081 0 09:50:53 pts/11 0:00 sleep 10000000 root 25911 22210 0 09:56:02 pts/10 0:00 grep sleep |
If you run a
man proc, you’ll receive the manual page for the /proc tools - highly useful.
How to Remove Empty Files
Simple one-liner to remove empty files older than 7 days:
|
1 |
# find . -type f -mtime +7 -size 0c | xargs rm |
How to Format seq Output
seq comes with the -f option, allowing us to specify a printf(3) format string.
For example, to zero pad seq output (five zeros):
|
1 2 3 4 5 6 7 8 9 10 11 |
$ seq -f %05g 1 10 00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 |
See: seq(1) printf(3)
How to View LDOM Configuration as a Non-Privileged User
If you try to view LDOM configuration information as a non-privileged user, you’ll probably be greeted with this:
|
1 2 |
$ /opt/SUNWldm/bin/ldm ls Authorization failed |
You can assign the “LDoms Review” profile to grant this privilege, i.e.:
|
1 2 3 4 5 6 7 |
$ su - # usermod -P "LDoms Review" username # profiles username LDoms Review Basic Solaris User All # exit |
Now, you can view the LDOM Configuration as the non-privileged user to which the privilege was assigned:
|
1 2 3 4 |
$ /opt/SUNWldm/bin/ldm ls Name State Flags Cons VCPU Memory Util Uptime primary active -n-cv SP 4 1G 0.3% 7d 23h 48m test-domain active -n--- 5000 6 4G 0.2% 7d 19h 55m |