The Official *nix Thread

Inane baanter or words of wisdom - you decide...
Post Reply
User avatar
JQW
Baaaaa!
Baaaaa!
Posts: 1186
Joined: Thu Feb 22, 2007 12:23 pm 0
Location: Ripon, where nothing ever happens.

Re: The Official *nix Thread

Post by JQW »

dom wrote:I found this on wikipedia, and thought people might find it interesting, perhaps even useful (although my current linux boxen only lock-up due to hardware faults, so I've not needed it)...

http://en.wikipedia.org/wiki/Magic_SysRq_key

Using a combination of alt+SysRq+letter, you can either print useful information to the console or messagelog, or sync disks, remout as read-only, kill processes on a specific virtual terminal, unmount disks, trigger a dump or force a reboot amongst others.
It's been around for many years. It has to be specifically enabled in the kernel.
drz
Posts: 9
Joined: Thu May 08, 2008 6:50 pm 0
Location: Carpinteria, CA, USA
Contact:

Re: The Official *nix Thread

Post by drz »

RageMatrix wrote:This is a completely minor issue, but I've noticed under bash that some of my directories (denoted in dark blue) have bright green backgrounds behind the text. I've looked at the directory permissions including user/group and they seem to be identical to directories that don't have this green background. Whats that all about? I wouldn't mind if I knew what it meant or perhaps turn it off as it makes the directory text fairly hard to read.
The way that ls assigns colors is pretty confusing.
You probably have an alias for ls, which really runs "ls --color=auto". This directs ls to look at an LS_COLORS environment variables, where you can fully customize the colors in a format that is super hard to read. But you probably don't have one of those, so the default values are used. The way to create an LS_COLORS environment variable is with dircolors, and dircolors also contains the default colors. You can see them in a fairly unhelpful format with "dircolors --print-database". But the information is there, and on my system a directory with a blue foreground and a green background means it's writeable by other (which is unix speak for everybody). Usually you should have few or none of those directories, which is why it gets the special color treatment.

Tim
User avatar
Firefox
Sheepie Whore
Sheepie Whore
Posts: 11412
Joined: Fri Apr 26, 2002 6:15 pm 0
Location: Sheffield

Re: The Official *nix Thread

Post by Firefox »

RageMatrix wrote:
dom wrote:I found this on wikipedia, and thought people might find it interesting, perhaps even useful (although my current linux boxen only lock-up due to hardware faults, so I've not needed it)...

http://en.wikipedia.org/wiki/Magic_SysRq_key

Using a combination of alt+SysRq+letter, you can either print useful information to the console or messagelog, or sync disks, remout as read-only, kill processes on a specific virtual terminal, unmount disks, trigger a dump or force a reboot amongst others.
Nice find - I suspect I might need to use this at work one day...;)
That used to be very handy years back when X would lock up occasionally (and I didn't have another Linux box to ssh into my main one). Magic sys request key combo, a couple of "S"'s to make sure the disks were synched (waiting for the drive lights to stop flickering inbetween), a "U" to umount all filesystems, and then an "R" to reboot. Always came back up sweet as a nut. :)
"I am a very considerate person. If I want to go out all night on my miniature golf course and shoot lizards, well, no reason to keep the neighbours awake..."
User avatar
teamonkey
Sheepie Whore
Sheepie Whore
Posts: 12082
Joined: Thu Jun 13, 2002 1:07 am 0
XBL Gamertag: itsthetaste
PSN: teamonkey_ca
Contact:

Re: The Official *nix Thread

Post by teamonkey »

A friend's Linux-based virtual server space keeps filling up and he asked me for some help. I'm a fairly competent Linux user, but clueless as an administrator. I ran "du -aSm | sort -n | tail" and it appears that there's 350MB in /var/spool/mail/ and 65MB in /home/httpd/logs/ - that'd be it then, I guess.

The question is now what to do with it? I suspect that something's gone wrong with the mail, but I don't know what the best solution is. I suspect that something's gone wrong with the mail, that it's clogged up somewhere? As for the logs, they date back only 12 months so I guess that they're deleted automatically after that point. How do I work out what's worth keeping or chucking? There's half a dozen small websites running on this vserver, but there should be ample space for them. In fact, they've been running well in this configuration for the past few years and it's only been the last couple of months that he's had problems.

Any advice that I can pass on? Cheers.
User avatar
defsdoor
Baaaaaa!
Baaaaaa!
Posts: 3909
Joined: Fri Jan 30, 2004 12:26 am 0
Location: Sunny Beduff

Re: The Official *nix Thread

Post by defsdoor »

Yeah - get a new HD - 350MB is hardly a lot nowadays :)

Does he actually use that server as a mail server ? If not then it's just local mail delivered to the default location. Change the MTA settings to use a smart host and push all the local email on to that. Otherwise - just delete it all routinely ;)
User avatar
stealthbanana
Baaaaaa!
Baaaaaa!
Posts: 2805
Joined: Wed Nov 09, 2005 11:59 pm 0
Location: Over Here.

Re: The Official *nix Thread

Post by stealthbanana »

A large amount of the 350mb will be the system emailing root and or main admin to tell them reports on what it has been doing, results of any system checks etc.

Point an email client at it and delete them as they arrive, or change the conf files for the processes emailing not to email the reports. I would urge the former though, just in case it wants to tell you something important.
Not long now before lollipop men are called Darren
User avatar
Dungeon-Dave
Baaaaaa!
Baaaaaa!
Posts: 3925
Joined: Thu Aug 04, 2005 12:01 pm 0
Location: UK
Contact:

Re: The Official *nix Thread

Post by Dungeon-Dave »

For mail - forward the mail off to another account (use the /etc/aliases, luke) or configure a POP client to tap in and read it. Find out where the emails are coming from (as stealthy said, probably a lot of notifications) and consider disabling some services or reducing verbosity of those notifications.

For logs - look at running logrotate and some other truncate programs. If the web logs are useful, use an analysis tool (like AWstats) to run through the logs to get some meaningful data and pretty graphs before ditching the logs.

I use logrotate and logwatch so that I get a daily email of activity before the logs are rotated off the system. Those mails often warn me if things are filling up.
teamonkey wrote:How do I work out what's worth keeping or chucking?
You don't. You tell him where the big files are, and it's up to him to examine him and determine their worth.

TBH, the question you've got to ask yourself is: if they've *just* been spotted, then how important are they? Clearly the logs were filling up undetected, so my guess is that nobody needed them.
User avatar
RageMatrix
Baaaaaaa!
Baaaaaaa!
Posts: 5515
Joined: Fri May 10, 2002 12:52 pm 0
XBL Gamertag: Jon256
Location: East Sussex

Re: The Official *nix Thread

Post by RageMatrix »

Couple of things...:D

1. I'm using the free DynDNS website to translate DNS for my router, which gets its IP changed every few days or so by my ISP. I've installed and have running the ddclient on the Linux box in question that the DynDNS service is supposed to forward to. This worked fine when I added the currently used router IP to the "My Hosts" section on the website, but now this IP has changed.
Is the ddclient supposed to automatically update this (because thats what I assume its supposed to do)? In my /etc/ddclient/ddclient.conf file, I've got the following information filled in: -

login=<my DynDNS account name>
password=<my DynDNS account password>
server=<the hostname I've given the Linux box on "my hosts" on DynDNS>

Is there anything else I need to do? Because unless the ddclient only updates very occasionally, I don't think its working and I don't see how it knows "where" my router is to check for the new IP. Disregard this question if its not easy, because I've posted this same question on the DynDNS forums too. Do I need to open a special port for this daemon to report back perhaps?

2. Just for fun, I've got vsFTPd server running on the same box on port 21. This is only visible within my own home network at the moment and is not open to the outside world as its closed off by the router firewall (because I don't know what I'm really doing yet!). I can login just fine within my network and its supposed to be set to a special user's home directory that I created just for this - I've denied access to everyone else except this special FTP user using the /etc/vsftpd/users_list to make sure only this user can login. Problem is, I'm still able to traverse the entire filesystem like any other normal user once I'm logged in - although obviously not change anything because I'm not root. Is there a way to set it so that the FTP user cannot leave its designated home directory?


BTW, TorrentFlux is utterly awesome :D
XBox Gamertag: Jon256
Wii Code: 4849 1090 9042 6725
"Wrapped in metal, wrapped in ivy"
The Official UNIX/Linux Thread
User avatar
defsdoor
Baaaaaa!
Baaaaaa!
Posts: 3909
Joined: Fri Jan 30, 2004 12:26 am 0
Location: Sunny Beduff

Re: The Official *nix Thread

Post by defsdoor »

You need to hook into dhclient_exit_hooks (or something like that) iirc. It's a script that gets called whenever dhclient changes your IP address. I'm on wintendo atm but will look later.
User avatar
RageMatrix
Baaaaaaa!
Baaaaaaa!
Posts: 5515
Joined: Fri May 10, 2002 12:52 pm 0
XBL Gamertag: Jon256
Location: East Sussex

Re: The Official *nix Thread

Post by RageMatrix »

In regards to the ddclient thing, I've discovered that although it looks as though its running, its actually SIGTERMing and crashing out. I suspect that this is because the fw=<whatever> directive isn't filled in which (I think) should point to a URL that your router reports its current dynamic IP from my ISP. Since the only interface for this I have is a web based one, it can't filter out all the HTML junk to get to the IP address. So, I think I might write a small IP script that filters out the HTML and just reports back the IP address.

Thats my guess anyway.
XBox Gamertag: Jon256
Wii Code: 4849 1090 9042 6725
"Wrapped in metal, wrapped in ivy"
The Official UNIX/Linux Thread
User avatar
defsdoor
Baaaaaa!
Baaaaaa!
Posts: 3909
Joined: Fri Jan 30, 2004 12:26 am 0
Location: Sunny Beduff

Re: The Official *nix Thread

Post by defsdoor »

Oh - you're PC isn't on that IP address - the router is - but you want to update dyndns from the PC ?

Check that your router doesn't do dyndns first - a fair few do. Otherwise doesn't the dyndns site have an option to detect your IP from the IP connecting to it - and not be told by the ddclient itself ? Just cronjob it then if it does.
User avatar
RageMatrix
Baaaaaaa!
Baaaaaaa!
Posts: 5515
Joined: Fri May 10, 2002 12:52 pm 0
XBL Gamertag: Jon256
Location: East Sussex

Re: The Official *nix Thread

Post by RageMatrix »

defsdoor wrote:Oh - you're PC isn't on that IP address - the router is - but you want to update dyndns from the PC ?
Erm....yes?
As far as I understand it, you enter a hostname on the DynDNS site and the IP that you want to get updated. The IP I've entered is the dynamic IP from the router. Any traffic that hits certain ports is forwarded to the Linux box, so essentially this IP is the IP I'm using from the outside world to contact my Linux box. The purpose of the ddclient is to report back to the DynDNS website the current IP of the router, which is what I think the fw=<whatever> is used for - to get the current IP of the router so that it can automatically update the DynDNS hostname so that regardless of the actual router IP, I can always access the router and, by extension, the Linux box behind it.

As the only way for the ddclient to get the current router IP is through an HTML interface, it can't parse the IP address from the router admin URL, so I think I'm going to have to write a little PHP script to filter out all the crap and use the URL to the PHP script to enter in the fw=<whatever> section of the ddclient.conf in order to do this.

Maybe :D I'm not really sure!
XBox Gamertag: Jon256
Wii Code: 4849 1090 9042 6725
"Wrapped in metal, wrapped in ivy"
The Official UNIX/Linux Thread
User avatar
RageMatrix
Baaaaaaa!
Baaaaaaa!
Posts: 5515
Joined: Fri May 10, 2002 12:52 pm 0
XBL Gamertag: Jon256
Location: East Sussex

Re: The Official *nix Thread

Post by RageMatrix »

Okay, think I've got the DynDNS thing sorted out with the ddclient - my ddclient.conf was wrong and the Orange LiveBox (obviously) wasn't supported by default, so I wrote a little PHP script to get the current IP of the router to send back to DynDNS.

Code: Select all

daemon=300                              # check every 300 seconds
syslog=yes                              # log update msgs to syslog
mail=root                               # mail all msgs to root
mail-failure=root                       # mail failed update msgs to root
pid=/var/run/ddclient/ddclient.pid      # record PID in file.
ssl=yes                                 # use ssl-support.  Works with
                                        # ssl-library

use=web, web=localhost:<port>/router/routerip.php
login=<DynDNS login>
password=<DynDNS password>
protocol=dyndns2
server=members.dyndns.org
custom=no, <hostname of the linux box>
...and the little PHP script simply looks like this: -

Code: Select all

<?php
$routerPage = file_get_contents("http://configuration.adsl/");
$routerPage = str_replace("\t", "", $routerPage);
$routerPage = str_replace("\n\r", "", $routerPage);
$routerPage = str_replace("\n", "", $routerPage);
$indexOfConnectedStringStart = strpos($routerPage, "Connected");
$ipAddress = substr($routerPage, $indexOfConnectedStringStart + 11, 15);
$ipAddress = ereg_replace('[<]', '', $ipAddress);
echo $ipAddress;
?>
Seems to work great so far. Now just need to work out how to confine an FTP user to its own home directory.
XBox Gamertag: Jon256
Wii Code: 4849 1090 9042 6725
"Wrapped in metal, wrapped in ivy"
The Official UNIX/Linux Thread
User avatar
tufty
Sheepie Whore
Sheepie Whore
Posts: 12524
Joined: Fri Jan 07, 2005 4:52 pm 0
Location: French Alps

Re: The Official *nix Thread

Post by tufty »

Does your Livebox not have a dyndns client built in? Mine does. Saves a *load* of buggering about.

http://<router ip here>/dyndns.html

Simon
"massive retard™", "full of shit™", "tiny bitch™", "retarted™", "a bit of a one trick pony™", "petty™", "simple minded idealistic twat™", "miserable humourless fucker™"
User avatar
RageMatrix
Baaaaaaa!
Baaaaaaa!
Posts: 5515
Joined: Fri May 10, 2002 12:52 pm 0
XBL Gamertag: Jon256
Location: East Sussex

Re: The Official *nix Thread

Post by RageMatrix »

Hmmm - apparently it does 8O Oh well - I've done it now :D Thanks, though.
XBox Gamertag: Jon256
Wii Code: 4849 1090 9042 6725
"Wrapped in metal, wrapped in ivy"
The Official UNIX/Linux Thread
Post Reply