UNIX/Linux

Displaying the host name of a UNIX server on login

September 27th, 2007    2 Comments

To show the host name of a server when you log in to it. Add the following at the end of your shell startup file (e.g. .bashrc or .cshrc in your home directory):

perl banner.pl

Then create the following Perl script in your home directory and call it banner.pl.

# Perl script for printing banner showing name of local host use Text::Banner;
$a = Text::Banner->new;
$a->set(`hostname`);
$a->size(1);
$a->fill('');
$a->rotate('h');
print "\n";
drawlines();
print $a->get;
drawlines();
print "\n";
print "\n";
sub drawlines() {
    for ($loop=1; $loop<4; $loop++) {
        for ($n=1; $n<60; $n++) {
            print "=";
        }
        print "\n";
    }
}

Finally, install the Text::Banner perl module  from CPAN. Note: if you don't want to (or can't) install the Perl module in the normal way on the server, you can  download the zip file from the CPAN Web site (http://search.cpan.org/~lory/Text-Banner-1.00/Banner.pm), gunzip and tar xvf it  in your home directory and then change the 'use' statement to:use Banner::Banner;

Now, when you log in to the server you get something like this (in this case the server is called pegasus):

pegasusbanner

Comments

  1. User Gravatar figjam said:

    April 18th, 2009 at 8:56 am (#)

    If you do not want to have it generated everytime, you can use a program called figlet (http://www.figlet.org)  on the linux/unix system. It does not usually come installed as standard. 

    You can install it in ubuntu (for example) by apt-get install figlet 
    The result is that you can generate text using different fonts. Once this has been generated, you can add it into the banner for the ssh/telnet/ftp server.

    -Cary

  2. User Gravatar Alistair said:

    April 19th, 2009 at 9:29 pm (#)

    Thanks for the tip Cary.
    I hadn't heard of figlet before.

Leave a comment

 

Starting Fedora in text-only or graphical mode

August 9th, 2006

The secret to whether your Fedora machine goes into text-only mode or graphical mode on startup is held in the file /etc/inittab

If this file contains:
id:3:initdefault:
Fedora will boot into text-only mode.

If the file contains:
id:5:initdefault:
Fedora will boot into graphical mode.

Comments are closed.



Graphical remote login

August 9th, 2006

Troubleshooting remote graphical sessions from a Windows PC to a remote Fedora machine.

X Sessions

1) Make sure you aren't being blocked by your firewall(s).

If you want to establish an X session from a machine on the internal network to a machine in your DMZ (e.g. your web server), you'll need to open up DMZ pinholes to allow the server in the DMZ to send screen data to ports 6000 (and, for some reason, 6001) on the Windows machine. If you're using Smoothwall you can do this quite easily in the Smoothwall admin pages.

For an X session, check that your firewall on the Windows machine isn't blocking traffic from port 6000 on the Windows machine to port 177 (XDMCP) on the server in the DMZ via the UDP protocol. If the firewall blocks this, the X manager on your Windows PC will not find the DMZ server even if its up and running and listening for connections on port 177.

2) Check gdm is running:

SSH to the server and enter the command:

ps -ef | grep gdm

This will tell you if gdm has been started.

3) If it's not running use the command:

gdm &

to start gdm

Be aware that gdm uses up a lot of processing power. If you have your server set up to boot up to run level 3 (text-only login), it will be sitting with a black screen and a login prompt. When you start gdm, this changes to a graphical login (although, of course, you won't see this if the server doesn't have a monitor). So when you've finished your remote X session, you should use the command:

gdm-stop

to stop gdm, switching the local display on the server back to the text-only login.

VNC

The main things for troubleshooting VNC are to check that you have SSHed into the server to open up the tunnel to port 590n (e.g. 5903 for display 3).

You should never allow direct VNC access to the server, only via a port forward tunnel opened by an SSH session. This means that your session info for the VNC client will be something like:

localhost:3

Which only works if port 5903 on the machine you're at has been forwarded to port 5903 on the server you've SSHed to.

If you HAVE SSHed to the server and you still don't get the authentication dialog box of your VNC client, check that vncserver is running on the server.

To do this use the command:

ps -ef | grep Xvnc

If there isn't an Xvnc process using display 3, start vncserver, telling it to use display number 3.

To do this, use the command:

vncserver :3

Just remember to stop vncserver after you close your VNC window:

vncserver -kill :3

Note: VNC may also be blocked by your firewall(s).

Comments are closed.



MySQL log in error

August 1st, 2006

If you try to log on to MySQL (e.g. using the simple mysql command) and you get a response like:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

It most likely means your MySQL is set up to authenticate logins and you didn't supply a user name and password. Try:

mysql -u root -p

Where root is the MySQL user (note: this is not a file system user account, even if it's got the same name as one). You will be prompted to enter the password.

If this still doesn't work, it probably means the user you're trying to log in as hasn't yet been added to MySQL's user database. To add a password for MySQL's root user do:

mysqladmin -u root password 'the-new-password'
Read the rest of this entry »

Comments are closed.



Getting Tomcat working on Fedora Core 5

July 30th, 2006

I finally got Tomcat working on my new Fedora Core 5 install.

However, I tried so many things, I'm not entirely sure what sorted it. I suspect it was installing tomcat5-webapps. I ran the following commands:

yum install tomcat5
yum install tomcat5-webapps
yum install tomcat5-admin-webapps

Note: yum install tomcat5 did nothing useful because Fedora Core 5 comes with Tomcat 5 and I'd done a complete yum update after installing FC5.

One of the other things I did yesterday was to add the following lines in /etc/httpd/conf/httpd.conf:

LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
ProxyRequests Off

# transfer URLs for 'convert'
ProxyPass /convert/ http://localhost.localdomain:8080/convert/
ProxyPassReverse /convert/ http://localhost.localdomain:8080/convert/

# transfer URLs for 'hs'
ProxyPass /hs/ http://localhost.localdomain:8080/hs/
ProxyPassReverse /hs/ http://localhost.localdomain:8080/hs/

I then restarted httpd.
And finally, since yesterday, I did a
shutdown -r now

This morning, I browsed to http://localhost:8080 in a browser on the Linux machine and Tomcat works.

I then opened up port 8080 in the firewall, so that I can see the Tomcat home page from other machines on the network by browsing to http://:8080.

So, at last, I've got Tomcat working. Now for Alfresco.

Comments are closed.



^ back to top ^

Page 2 of 912345OlderLast »