PDA

View Full Version : Miscellaneous tricks and tools on Linux CLI



Harry
08-16-2009, 09:35 PM
Find out what software a website is using


curl -D o -A "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2" http://insert-epic-website-here.com && clear && echo "This website is running:" && grep Server o

Into a Linux terminal. Make sure cURL is installed. Now when you run it, it will output the software the website is running :)


~villavu.com
This website is running:
Server: Apache


This website is running:
Server: lighttpd


All this procedure does it output the headers that the website says. It is not completely accurate, as all the admin must do is edit the file to change the headers. Also, it will output all the headers into a file named `o' in your home directory :)




How to use "screen".
screen is a program that is in Linux that allows you to run programs in the background, and also so you may keep a process running, even after you close your terminal.

So, say I wanted to use irssi [a nice CLI IRC client]. I would:

screen -SU irssi
The name of the screen, "irssi", is irrelevant. Simply set as something that is easy to remember for you.

Now, it will be a blank terminal. Now, just run whatever commands you want in there, this case being `irssi'.


Now when you are done with that, simply ^Ad out of the terminal. In human-speak, that means to Ctrl + a, then Ctrl + d. Now you should be back to the main window where you attached from. Great success!

Now that you want to hop back into that irssi screen, simply:

screen -Urx irssi
VoilĂ ~! There's your irssi!

Now, you can run:

screen -ls
It will show all of your screens, and their current status.





How to run your own webserver at home
Now things get serious, and also fun. Now that you have Linux, you also have the best operating system to run a server off of. My personal favorite server program is "lighttpd". It is very lightweight, yet powerful! Other people prefer apache2, but it is very fat and resource consuming compared to lighttpd.

To install it, let's take the easy road.

sudo apt-get install lighttpd
After that is done, simply:

sudo /etc/init.d/lighttpd start

Now it is running, and people can access any files you host there, as long as your ports are forwarded. Simply move files you want them to be able to access into the /var/www/ folder.
If you can not open your site (which you can go to by http://*your ip address*; find it at http://seemyip.com/ ) through a proxy [nor can others], your ports are probably not forwarded. Read the next article :)




How do I forward ports?
As you are probably enjoying the ease of use of Linux servers, you must know how to forward ports off your router. It is simple to do, once you find out how. All routers are different in their WebUI.

You can get to your WebUI by going to, either http://192.168.1.1 , or http://192.168.0.1/ .... if neither of those work, then refer to your router's manual on how to access it.

Now that you have loaded that screen, it should ask you for a password. The default passes usually are:

Username: admin
Password: cableroot

Username: admin
Password: admin

Username: admin
Password: password

Username: root
Password: root
If none of these work, please refer to your router manual.

Now, there should be a tab there that will say "Applications", "NAT" [on ddwrt it is like that], "Forwarding", or something similar to that. Now open it. It will ask for a beginning range, and an end range, and also an internal IP to forward it to.
Open a terminal to find your internal IP address.

ifconfig | grep "inet addr"
My output is

inet addr:127.0.0.1 Mask:255.0.0.0
inet addr:192.168.1.120 Bcast:192.168.1.255 Mask:255.255.255.0
You obviously do not want the one that says 127.0.0.1. Chose the one that says 192.168.*.*, as that is the correct one. Do not chose the Bcast IP.

Now, in the case of a webserver with lighttpd, you want to forward port 80. Just put down 80 for the begin, and ending ports. Enable it, chose it into your internal IP address you just got above.

Now, you should be able to load your page via a proxy, or someone else can load it fine. Grats!

If it does not load still, then it is highly possible your ISP is blocking the ports. Your ISP sucks :mad: ..... it is easy to workaround though! In the case of lighttpd, simply edit the config file.

sudo nano /etc/lighttpd/lighttpd.conf
^W (ctrl + w) for "server.port". Uncomment it (remove the # sign before it), and change it to whatever port you want to use. Save the file with ^O, then exit with ^X. Now reboot lighttpd.

sudo /etc/init.d/lighttpd stop
sudo /etc/init.d/lighttpd start
....and reforward the correct ports. It should load now! If not, you have issues. Experiment with it a bit.





Commands you NEVER want to run
http://ubuntuforums.org/announcement.php?f=326

Just do not run any code that looks unsafe. :p It is easy to mess up your Linux with a simple command. Just do not hang around meanies. :rolleyes:











I can not think of anything else that might be interesting on this mini-tut. Feel free to ask questions about simple stuff that people might do daily that would be useful :)

Have fun!
~ Harry

Mr.Klean
08-17-2009, 08:06 AM
Hmm, have a fix for Ubuntu with down syndrome? Meaning that none of my settings are ever remembered?

Harry
08-26-2009, 03:53 PM
Hmm, have a fix for Ubuntu with down syndrome? Meaning that none of my settings are ever remembered?
I dunno, :(

Wizzup?
08-26-2009, 04:50 PM
Hmm, have a fix for Ubuntu with down syndrome? Meaning that none of my settings are ever remembered?

All settings?

cycrosism
08-26-2009, 07:26 PM
Apache2 rules

Harry
08-26-2009, 07:46 PM
Apache2 rules
http://i32.tinypic.com/id7pee.jpg

It rules if you want to have a bloated system, you are correct. Ask any smart Sysadmin which server software combinds speed, with powerfulness. They WILL say lighttpd.

Daniel
08-27-2009, 05:11 PM
Just do not run any code that looks unsafe.

You should change that to: "Don't be a cycrosism and run anything from anyone. Use your common sense and don't run any code that LOOKS unsafe - or if you really want to run it, just Sandbox it." :)