Sometimes, when copying a shell script edited on a Windows machine to a linux machine, you will have the an issue relating to a “bad interpreter”. This can be caused by Windows CRLF vs Linux CR. A simple fix is to use the following perl command on the file.

perl -i -pe's/\r$//;'

( is the name of the file to be fixed)

A linux system admin is commonly tasked with changing permissions on directories. A helpful solution is creating a shell script to handle the workload for you. The below example can be modified to suit your needs of automatically creating a shell script that does what you need it to do on a large scale.

First, we need to create a file list of all the directories of a folder.

ls >> list.txt

You should now have a file with one folder per line.
Next, you will want to use the sed command to insert your command at the beginning of each line before the folder name.

sed 's/^/setfacl -R -d -m g::rwx /' list.txt >>

sed – linux sed command
' – opens argument
s/ – option
^/ – inserts at beginning of line
setfacl -R -d -m g::rwx / – text to add (close command with /)
' – closes argument
list.txt – filename to apply argument
>> – output to filename

Finally, make the shell script (in this case ‘’) executable.

chmod +x

Execute the command on your linux machine.


If using this example, your folders should now have their group rights acl set recursively.

Simple task using the find and attrib commands from the OES linux system shell.

find /media/nss/VOLNAME -exec /sbin/attrib {} -c=di \;

That’s it. It can take a while depending on the structure, but it will return results in realtime.

How it works:

The linux find command will display the path names to the current directory (or in this case, the path specified)

It is then told to execute (-exec) the NSS attribute (attrib) command.

The clear (-c) command is followed with an equals (=) sign and the requested attributes to clear (in this case ‘di’ for delete inhibit)

Alternatively, you can set use the above command to set attributes by changing the -d= to -s=

Here are all the attributes:

all - All (used only for the Clear option)
aa - Attribute Archive
ar - Archive
cc - Cannot Compress
ci - Copy Inhibit
cm - Compressed
dc - Don't Compress
di - Delete Inhibit
ex - Execute
hi - Hidden
ic - Immediate Compression
ip - Immediate Purge
ln - Link
mi - Migrate Inhibit
ri - Rename Inhibit
ro - Read Only
sd - subdirectory
sh - Shareable
sy - System
tr - Transactional
vo - Volatile

In the user root’s home directory (or user in question), enter the folder:

cd .vnc

Open ‘xstartup’ with vim editor

vim xstartup

Comment out the current window manager (normally twm) and enter ‘gnome &':
(Should look similar to below)(Use ‘i’ to enter insert edit mode)


xrdb $HOME/.Xresources
xsetroot -solid grey
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#twm &
gnome &

(when finished, escape out of insert mode {ESC})

Save the file


Kill any open xsession:

vncserver -kill :2

Restart vncserver:


On the next connect via VNC, you should have a gnome desktop staring back at you.

Find the PTS connection number of the logged in user that you wish to kick:

zero_serv:~ # who
root tty1 Sep 19 08:13
root pts/0 Jan 18 12:59 (
root pts/1 Jan 18 13:07 (

In this example, we want to kick the ‘root’ user that is on ‘pts/1′. (Notice that the connections are labeled by IP)

Issue the command:

zero_serv:~ # ps x | grep ssh
2973 ? Ss 0:00 /usr/sbin/sshd -o PidFile=/var/run/
8006 ? Ss 0:00 sshd: root@pts/0
8068 ? Ss 0:00 sshd: root@pts/1
8176 pts/0 R+ 0:00 grep ssh

(Note: depending on the system, you may need to issue this: ps -aux | grep ssh)

As you can see above, PID 8068 is the culprit.

Issue the command:

zero_serv:~ # kill -9 8068
(Where 8068 is your PID)

The session will now be killed.

As with the Cisco commands, I normally forget commands. This is just a reference of some commands.

Read scsi devices, memory, cpu
cat /proc/scsi/scsi
cat /proc/meminfo
cat /proc/cpuinfo


echo "- - -" > /sys/class/scsi_host/hostX/scan
X stands for the SCSI bus to scan

cat /sys/class/scsi_host/hostX/proc_name
X stands for the SCSI bus to list

SCSI device information
scsiinfo -l

Find files less than a day old:
find . -type f -mtime -1

Find files modified more than a day ago
find . -type f -mtime 1

Hardware info
hwinfo more | grep

Disk space (human readable sizes)
df -h

Update timeserver
ntpdate -u

OES version
cat /etc/novell-release

SLES version
cat /etc/SuSE-release

Folder size
du -sk DirName

Hardware serial number (Use on Dell/HP servers – probably others)
dmidecode|grep "Serial Number"

SCP is great for transferring files between linux boxes.

Example commands:

Copies files from a remote server to the local machine:
scp /home/andrew/copy_me.txt

Copies files from local machine to a remote server:
scp /home/andrew/copy_me.txt

-p Preserves the modification and access times, as well as the permissions of the source-file in the destination-file
-q Do not display the progress bar
-r Recursive, so it copies the contents of the source-file (directory in this case) recursively
-v Verbose mode for viewing debugging messages
-P Specifies port used
-q Quiet mode: disables progress meter as well as warning and diagnostics messages.
-l Limits the used bandwidth, specified in Kbit/s
-C Compression enable
-c Change the enycrption cipher. (common values: 3des (default), blowfish, des)