UNIX – Fork Explained
Mr. Peabody Explains fork() Introduction How Windows Does It How Unix Does It So Why Do People Want the Unix Way? How does it work in Perl? Introduction UNIX – Fork Explained Say, Mr Peabody. I was just reading through the Perl 5.6 release notes and noticed that a new function called fork() is now […]
Read MoreUNIX Perl – Get local IP with ifconfig
UNIX Perl – Get local IP with ifconfig Replace ETH0 with the interface you need.. my $IP = `ifconfig eth0| awk ‘/dr:/{gsub(/.*:/,””,\$2);print\$2}’`; $IP =~ s/\s+$//;
Read MoreUNIX Boot Mode – Run Levels
UNIX Boot Mode – Run Levels Runlevel “3” will boot to text or console mode and “5” will boot to the graphical login mode ( “4” for slackware) Runlevel Scripts Directory (Red Hat/Fedora Core) State 0 /etc/rc.d/rc0.d/ shutdown/halt system 1 /etc/rc.d/rc1.d/ Single user mode 2 /etc/rc.d/rc2.d/ Multiuser with no network services exported 3 /etc/rc.d/rc3.d/ Default […]
Read MoreUnix find and replace text within all files within a directory
Unix find and replace text within all files within a directory Trying to do a search on an entire directory, finding all the instances of the text “applicationX” and replacing all instances with the text “applicationY”. find /path/to/start/from/ -type f | xargs perl -pi -e ‘s/applicationX/applicationY/g’
Read MoreSCCS – script header
SCCS – script header While sccs checked out a file, add these lines to the top of your script to preserve versions and file information. [bash] # Master: %P% # SCCS id: %Z% %M% %I% %E% [/bash]
Read MoreVNC server on Unix
VNC server on Unix Starting the VNC server on Unix for the First time VNC Server installs in /usr/local/bin, you need to make sure you have both /usr/local/bin and /usr/openwin/bin in your path, also the first time you run vnc you need to setup a vnc password, this is done with the /usr/local/bin/vncpassword command. After […]
Read MoreChecking Memory on UNIX
Checking Memory on UNIX [bash]ps -A –sort -rss -o comm,pmem | head -n 11[/bash] [bash]ps -auxf | sort -nr -k 4 | head -10[/bash] [bash]free[/bash] [bash]free -m[/bash] [bash]ps aux | awk ‚Äò{sum +=$4}; END {print sum}‚Äô[/bash]
Read MoreSearch String in Directory – UNIX
Search String in Directory – UNIX How to search for a string in a selection of files (-exec grep …). [bash] find . -exec grep “searchstring” ‘{}’ \; -print [/bash] [bash] find . -exec grep “searchstring” ‘{}’ \; -ls [/bash] This command will search in the current directory and all sub directories. All files that […]
Read More