Tag Archives: Command line

Finally a Linux jmx query tool that works out of the box!

I've tried many many jmx query tools from the command line, 
windows has the jconsole tool which is a part of the Java binaries pack, and works fine, 
but it is not a command line tool – it has a nice GUI. 

this command line jar works like a charm, 
displays all the beans it finds, and allows you to invoke them , 

take a look at :

http://crawler.archive.org/cmdline-jmxclient/

only the cmdline-jmxclient-0.10.3.jar files is available for some reason, 
searches in google didnt find the newer file at all. 

than you run it with :

java -jar cmdline-jmxclient.jar – SERVER:PORT

to get a listing of all the available beens.

more samples are available on the link above. 

works like a charm!

 

Technorati Tags: , ,

NFS mount – When Your Shares Go Wrong

From Wikipedia:

Network File System (NFS) is a network file system protocol originally developed by Sun Microsystems in 1984, allowing a user on a client computer to access files over a network in a manner similar to how local storage is accessed.

So basically its a network share, it allows you to share files between remote computers
in the most easy and seamless way, once it was specifically for UNIX servers,
but today NFS is supported over MS servers as well.

Like everything else in Sysadmin life,
when its working its working well, and nobody hears about it,
but what to do when its not working?
Samba debugging for example is easier from that aspect since it has extensive logs for the sysadmin,
NFS doesn’t keep logs, and NFS issues doesn’t show up in the syslog/messages file as well.

But there are tools that allow you to get extensive information about the running NFS process,
shares, statistics, users connected etc :

Description

Command

see what the machine is exporting SunOS: # exportfs
Solaris: # share
Print the list of shared file systems showmount -e server_name
Print the list of all clients mounting a directory from the questioned server showmount -a server_name
Print the directory and all the clients that are mounting it curretly – from within the nfs server dfmounts
print the nfs netwrok statistics client side: nfsstat -c
server side: nfsstat -s
To see that nfsd is responding rpcinfo -T udp crimson nfs
To see that mountd is responding rpcinfo -T udp crimson mountd
To see that lockd is responding rpcinfo -T udp crimson nlockmgr

rpcinfo -T udp crimson llockmgr

Technorati Tags: , , ,

I Like Good Linux Lists On The Morning

Lists are the magic word for SEO and link bait, and they catch the eye.

Well I sometimes bite too so here is the latest Linux links list I have fallen for:
15 Power tools for Linux that you cant afford to miss,
I havent checked all the links in the page yet, but I will.

And you should probably check out the whole blog,
It looks very promising and fun to read.
from their description:
Penguin Inside is a blog about Linux and Software Guides, How-TOs, Reviews.
The blog is dedicated to Linux Desktops.

Another Good list is from Smashing Magazine:
50 Beautiful Flash Websites , and thats a beutiful list of 50 stunning flash websites,
A couple that i liked the most are:

e-Content Solutions

econtent

and v5 Design

v5design_s

Technorati Tags: , , ,

Apache Active Directory Authentication

Apache server is a strong web server that can serve great open source application like Mediawiki which is a great solution for information sharing,
but what if you want to use Mediawiki to share information only for the local office active directory domain members?
Or even only to members of a specific group in the active directory?

In Apache you have a specific module called mod_ldap which allows you to use the Active Directory as an authentication server for your users,
so you can create a secure wiki branch for each department users.

To setup the apache server to use Active Directory as access manager you will need to make sure the mod_ldap was compiled with the apache server and that these lines are in the httpd.conf file:

LoadModule authnz_ldap_module modules/mod_authnz_ldap.so
LoadModule ldap_module modules/mod_ldap.so

If you have a Windows server installed with the xampp install of apache and mysql, you will have the module pre-compiled into the apache server,
however testing that it’s loaded can be done with:

C:\xampp\apache\bin\httpd.exe -t -D DUMP_MODULES
the output should have these lines:
authnz_ldap_module (shared)
ldap_module (shared)

Once you have the mod_ldap modules loaded you can add to the apache configuration file the user authentication support:

Any Authenticated user from the Domain:

<Location /Finance_Wiki>
Require valid-user
AuthType Basic
AuthName “Finance Wiki Access”
AuthBasicProvider “ldap”
AuthLDAPBindDN “CN=proxy_user,OU=sub_group,OU=main_group,DC=some,DC=domain,DC=com”
AuthLDAPBindPassword “proxy_user_pass”
AuthLDAPURL “ldap://pdc.some.domain.com:389/OU=main_group,DC=some,DC=domain,DC=com?sAMAccountName?sub?(objectClass=*)”
</Location>

The AuthLDAPBindDN and AuthLDAPBindPassword settings are for setting a user that will allow the apache server to browse the Active Directory structure,
the user created for this should have the minimum rights possible in the domain.

This specific apache configuration will allow any user from the domain to share the /Finance_Wiki folder, but if you want to allow access for a specific group you need to add this configuration line:

require ldap-group CN=groupname,OU=group.container,OU=main_group,DC=some,DC=domain,DC=com

This is the part that will require the active directory authentication for a specific group.

This way you can prepare a wiki branch for each group in your company to securely share internal files.

Technorati Tags: , , , , ,

Computer Jokes

Syntax Error

I found these bunch of old geek jokes in this post today,
that combined with the red wine glass  had for lunch made working in the afternoon impossible :)

the couple I loved the most were:

Unix is user friendly. It’s just very particular about who its friends are.

and another unix joke – a true classis:

Why programmers like UNIX:

unzip, strip, touch, finger, grep, mount, fsck, more, yes, fsck, fsck, fsck, umount, sleep

Technorati Tags: , ,

Test http server from windows command line

curl for windows

So you went ahead and did a little change to your web site, or web server redirect,
and you want to test it out without a sniffer,
the fastest way to test the http server headers and output is from the command line so you can see exactly what the servers is sending.

Now from Linux you have built in tools like GET, and wget ad curl,
wget and curl you can also install on windows to work from the command line.

Curl For Windows

Go ahead and download curl from their main website, you should get the Win32 – General version,
or the Win64 binary.
Better take the SSL enabled version if you will ever need to test SSL.
Take the curl.exe file from the zip file and place it somewhere in your windows PATH.

To find which directories are already in the windows path open the command line and write:

C:\>echo %PATH%

You will get the listing for such directories, just place the curl.exe in one of them.

Now for the tests:
To get only the headers and not the file contents itself use “curl -I http://address”

C:\>curl -I http://some.site.com/blocked_folder/blocked.php
HTTP/1.0 403 Forbidden
Server: Apache
Accept-Ranges: bytes
Content-Type: text/html
Expires: Tue, 27 Oct 2009 19:32:38 GMT
Cache-Control: max-age=0, no-cache, no-store
Pragma: no-cache
Date: Tue, 27 Oct 2009 19:32:38 GMT
Connection: keep-alive

From this test you can see the file is forbidden, what are the caching setings for the server, and other headers information.

If you would like to see the full page contents just remove the “-I”.

another sample:

C:\>curl -I http://www.cisco.com/
HTTP/1.1 200 OK
Date: Tue, 27 Oct 2009 19:36:28 GMT
Server: Apache/2.2
Set-Cookie: CP_GUTC=62.214.121.218.123463458258569; path=/; expires=Sat, 21-Oct-34 19:36:28 GMT; domain=.cisco.com
Last-Modified: Tue, 27 Oct 2009 16:34:14 GMT
ETag: “5985”
Accept-Ranges: bytes
Content-Length: 22917
CDCHOST: cdcxweb-prod1-02
Content-Type: text/html

this time we got a 200 reply which means the apache sent us the page,
we can see the page’s size from the “Content-Length” header,
and the other info the apache wants to send us.

Testing for Virtual hosts

Virtual hosting on apache can mean having more domain names on the same IP,
and you can test each of these domains by adding a “Host” header to the curl test line:

curl -H “Host: sub1.host.com” http://www.hosting.com/
curl -H “Host: sub2.host.com” http://www.hosting.com/

These 2 lines will bring back the html code for each of the different virtual hosts on the same server.

Here are some more ideas of using curl -for example:
Sending POST data through curl

Technorati Tags: , , ,

How to Debug Samba Server and solve user connection problems

samba_linux

Samba is the server used to share files from a Linux server to the rest of the windows clients in an office,
it is  an easy to use server with simple defaults that will make the integration easy into any domain,
you can find on the samba main site some configurations samples and newer smb.conf samples to help ease the server into the domain.

But the harder part after setting the server is debugging problems with it,
like a user permission problem – can the user authenticate to the Microsoft domain server?
maybe he has a password problem? maybe he doesn’t have permission to access the share?

Setting up samba logging:

For starters you will find all the config files are at /etc/smb
the main config file is smb.conf,
other important files are smbusers and smbpasswd,
smbusers is a mapping file, to mask windows user as a linux user for access.

Now first thing to do when debugging is to setup the logging well,
so these are good log settings in the /etc/samba/smb.conf for debugging of the samba service:

log file = /var/log/samba/%m.log
syslog = 0
log level = 3 passdb:0 auth:0 winbind:0 vfs:0
vfs objects = full_audit

  • log file = /var/log/samba/%m.log                             the %m is substituted for the machine name.
  • syslog = 0                                                                             0 means only LOG_ERR will be sent to the syslog,
    If you want more info to be sent there change it to 3
  • log level = 3 passdb:0 auth:0 winbind:0 vfs:0        gives better control over which options to log
  • vfs objects = full_audit                                                  this allows for full details on which files are accessed by whom.

With this configuration all the machines log files will be found under /var/log/samba/*.log
for a sample, if you been trying to connect to the samba server from a machine named “boo1″
you should see in the log folder: /var/log/samba/boo1.log

You can search inside the folder by using “ls –latr” to find the newest files,
which will mean the windows clients that have been trying to connect to te samba server.

And “tail -100 machine_name.log” to view the errors you got if you couldn’t access the share.

Real life Debug sample:

from the file temp1.log:

nmbd/service.c:make_connection_snum(314)
user ‘temp1′ (from session setup) not permitted to access this share (share2)

This error means to that your user is known as temp1,
and temp1 doesn’t have permission to access the share “share2”
in which case you need to open the smb.conf and setup the permissions
for the user on this share to allow him access.

Inside smbusers you can map windows users to a specific unix user with this syntax:
unix_user = MY_DOMAIN\windows_user1 MY_DOMAIN\windows_user2 MY_DOMAIN\windows_user3

And then allow access to shares in the config by using the unix name:
valid users = unix_user

Checking access to the server and listing shares on it from commend line:

smbclient -L //server -U windows_user

You will be prompt for password, and if the settings are good, you will receive the shares listing from the server.

Connecting to a share on the server:
smbclient  //server/share -U windows_user

after answering the password you get a command line much like ftp:

smbclient //server/share -U builder
Password:
Domain=[MY_DOMAIN] OS=[Unix] Server=[Samba 3.0.33-3.7.el5_3.1]
smb: \>

mounting windows share on linux from fstab:

This will allow for automatic mount in case of server reboot:

\\server\share /unix_location  smbfs  credentials=/etc/samba.sharepasswd,uid=unix_user,gid=unix_group,ip=192.168.0.1,lfs 0 0

Contents of /etc/samba/.sharepasswd should be windows user and password to connect to the share:

username=windows_user

password=windows_pass

Getting info from a windows domain controller for samba debugging:

To list all the windows domain users from linux command line:

net rpc username -S icq-mdc1

replace “username” with a valid windows user name, to list all the users in the server,
you will need to know the user password as well.

This command can list the user groups from the domain controller:

net rpc user INFO username -S domain-server-name

replace “username” with a valid windows user name.

Technorati Tags: , ,

How to start learning Linux

If you want to start learning Linux the best advice I can give you is:

Start out as a user first

The simplest way is to download some live CD from the Internet,
for a sample this one:
Centos live CD
or: 
Fedora liveCD
Either of which will boot into a full working Linux distro,
without installing anything on your windows box.
when your done playing with the Linux server, just remove the CD from your computer, and reboot – your windows will come right back.
both the distros I’ve linked to here are very similar – they use the same redhat code, but the fedora is more cutting edge development version of everything and the centos is a stable server environment.
The fedora LiveCD will also allow you to install it to the machine your using from the LiveCD itself – after the boot you will see an install Icon on the Linux desktop.
Start playing with the servers, while reading some linux tutorials,
start as a Linux user and then work your way up to power user and to admin in the end.

Hands On Training Tasks for Linux Sysadmin

After your feel you know your way around as a user:

  • reading and writing files
  • working your way around the file system
  • installing some rpm packages

You can start working your way through some serious hands on training – try to do either of these:

  • Setup A stand alone DNS server
  • Setup Apache server with php and SSL
  • Install MySQL server from sources
  • Setup sendmail
  • Install WordPress or Joomla on your Apache/MySQL and happily see it all working together

Each of these tasks will take a long time to figure out for the first time, and on the way learning to do the task, you will learn a lot more things that you wouldn’t have just by playing with the server.

Technorati Tags: , , , , , , ,