Archive for July, 2007

Ping host measured in microseconds

Problem You want to ping a host on a given port and record time taken in microseconds.The following solution uses PHP socket libraries to open a connection, to the given host and port – then just close it again. By obtaining the microseconds before and after, it is able to deduce time taken in microseconds.Additionally [...]

AIX ODM removing device

Problem Someone removes a tty, printer, etc by doing rm /dev/lp3.Then you cannot recreate the device, as system returns “already defined at that location”. Solution You can try to recreate the device with mknod, but need the major/minor numbers.Then do rmdev -l lp1 -d.To get major, minor numbers you need to query the ODM. Example [...]

who command 5 ways

Problem You want to know who is on the system. Or which userid you are using.What runlevel you are at – or when the system was booted.All doable with who. Solution See the example and reference tabs, to see 5 ways to run who, showing different things about the system and users. Example 1. Basic[marcus@bagend [...]

List files 12 ways

Problem You want to list files under UNIX! Here I show 12 different ways to do it. Solution See the example and reference tabs. Example 1. Basic[marcus@bagend Perl_Bin]$ lsd-dump-tst.pl demo-ldap-entry2.pl demo-ldap-entry5.pl ldap-to-sql.pm logcam.pm showstat.pldemo-ldap-entry1.pl demo-ldap-entry3.pl demo-ldap-entry6.pl listenport.pl perl_eval_pattern.pl showtime.pldemo-ldap-entry1.pm demo-ldap-entry4.pl ldap-to-sql.pl logcam.plscanport.pl2. Long[marcus@bagend Perl_Bin]$ ls -ltotal 68-rwxr–r– 1 marcus adm 335 Sep 12 2005 d-dump-tst.pl…-rwx—— [...]

Permissions extension setfacl

Problem You want to allow access to files or directories, without giving exclusive use of a given group, user, etc. Solution Use setfacl. See the example and reference tabs. Example setfacl -m user:USERID:rw- filenamegetfacl filenameCan also do this: getfacl filename1 | setfacl -f – filenamePerforming an ls -ld filename, will show a plus in the [...]

Linux dircmp – directory compare

Problem I wanted to run a dircmp with the -d option, to show all files that are different.Plus display those differences.Linux replied – command not found! Solution Just diff the directories, with the -d flag. See the example and reference tabs for more info. Example diff -d dir1 dir2 Reference Technorati Tags: UNIX, Linux, Dircmp, [...]

Redundant key strokes

Problem Carrying on with my lazy steps, there are bits of code used with UNIX commands, which are completely redundant. Solution Save yourself some key strokes, remember these examples. Or come back to unix.coding-school.com and check them out again. Example chmod a+r filenameThe "a" is redundant – if you just do a "+r" – all [...]

Restarting Linux services boot time

Problem Every time you reboot your Linux Box – web server, samba server, etc is down. Solution Use chkconfig. See the example tab and then reference tab for man page. Example Show all serviceschkconfig –listList just httpdchkconfig –list httpdChange restart settings so web server starts at run level 5.(do a runlevel to see normal level [...]

Lazy tip – wrong password

Problem You start typing your password in UNIX, then realize – hold on that ain’t right.Sometimes your control c it – other times just hit enter and do it again.There is a quicker way. Solution When your sat at that password: prompt and lord only knows what you’ve typed. No problem – just do one [...]

YUM fails with 404

Problem If you (like me) was well keen, to get your shiny new fedora core 5 system up and running. Then you run yum and think, hang on that ain’t right – 404. Linux is better than this!! Solution Don’t bother searching the news groups, for posts that go nowhere (like I did for close [...]