8 Linux Commands That Will Save Your Day
Linux is a free and open source kernel that powers a variety of operating systems for servers, desktops, laptops, netbooks, mobile phones, and many embedded devices.
If you have your own Linux server, you have probably used SSH to access the command line on at least a few occasions when your web-based control panel simply would not suffice. The following are eight commands you can use in Linux that will save you time, energy, and maybe even money.
1. grep – While you could simply describe grep as a search tool, it is really so much more. You can filter long lists, scour documents for the most obscure detail, and make other commands behave differently according to your specifications.
example:
ls -al | grep make
2. ps – When you need to figure out exactly what is going with your server, ps is invaluable. In its most basic functionality, it lists processes (instances of programs currently running). With a few choice flags, you can view process IDs, memory and CPU usage, command names, and even parent and child processes.
example:
ps aux
3. locate – Lose something? There are more intricate ways to search with “find” or “grep”, but locate searches a pre-loaded database of all of your files, which makes it fast for those quick searches for misplaced files. In order to use it, you need to run updatedb to have the latest files indexed.
example:
locate money.html
4. top – Monitoring your system is critical. The ps command gives you every running process, but top only shows the most hungry of the bunch. If your server is running slowly, top may lead you straight to the culprit. It displays CPU usage, memory usage, system load, and much more.
example:
top
5. kill – Yes, this is a real command and perhaps your most powerful weapon. When a program is out of control or when an application freezes, kill will become your best friend. Using data from ps and top, you can determine which processes are causing trouble and what their PID (process ID is).
examples:
kill 23849killall pythonkill -9 23849
6. who – This is a very simple command with a very important purpose. When you are running a dedicated server, you will most likely have other users connecting to it. Even if you do not, it is a good idea to monitor user accounts in case hackers manage to penetrate your security. The simple who command will tell you which users are logged in and what time their sessions began.
7. history – You will probably repeatedly type the above-mentioned commands and many others as you manage your server. Every time you need to run them again, you could always type them, but if the command you typed was a lengthy string, that can get old very quickly. The history command shows you a list of your previous commands. In a Linux terminal, you can press the up arrow to navigate through the list or type “history” to get the full list. Use the “!” key to quickly execute a command associated with a particular history number.
examples:
history!75
8. cat – This command gives you a quick way to print the contents of a file on your console screen. It is designed for text-based files, and you can use it in combination with more, less, grep, and other commands to determine how the text is displayed. You can also use the “>” to save the output to another file.
examples:
cat testfilecat testfile | grep “important sentence”cat testfile | lesscat /proc/cpuinfo > /home/username/mycpuinfo
These Linux commands are common, and most web hosts, such as Manchester managed server company 34SP.com, provide them as part of their standard Linux server installations. The examples provided just scratch the surface of these powerful commands. To unlock their full potential, you should reference the manuals for each. You can read the manuals online or type “man” followed by the command name from your system shell (example: man grep).
Tavis J. Hampton is a librarian and writer with a decade of experience in information technology, web hosting, and Linux system administration. His freelance services include writing, editing, tech training, and information architecture.
How to Setup a FTP Home Server – Part2
To speedup the process, I decided to use a graphical front end for ProFTPD, the GADMIN-PROFTPD.
Steps to configure the FTP Home Server :
1. Install Gadmin-proftpd.
2. Setup the NAT in Modem / Router
4. Start exchanging files.
1a. Download the package gadmin-proftpd for your distro here
1b. Install dpkg-i or rpm-i package (depending on your distro. Or if it’s already in the repos of your distro, even better)
The gadmin-proftpd installs Proftpd automatically.
2a. Access your modem / router and configure Advanced Port Forwarding Rules.
2b. You must set the rules for nat modem / router so the external FTP requests can reach the FTP server on the internal network.
2c. In the example below, I configured as external port of the FTP in 2121, because the ISPs block low ports (less than 1024).
2d. And, I made requests to the server data ports (65524-65534) to reach the FTP server. These data ports are set in the FTP server ProFTPD, in passive mode, and will be passed to the client.
2e. Note that the item described in red is the internal IP address where the FTP server will be.
- Inform the external IP of your modem / router (which is indicated in red external IP here)
- Mark configure NAT routing: ON
- Now comes the configuration of the range of ports for passive FTP. I put on 65524-65534
- Other options may be equal to the figure.
- Set to binary mode file transfer.
- Now, continue configuring proftpd.
- Default home directory might be / var / ftp / click_here
- Now, an important item: Download speed and upload speed. These two values are what will determine the speed of your downloads / uploads. I recommend leaving at 1 / 3 the value of the nominal bandwidth, to provide room for other traffic.
- Allow resume of broken downloads and uploads mark ON
- Now click the Users tab
- Add a user (or more than one if you want to exchange files with more than one friend at the same time)
- Please mark the shell as / bin / null, on the creation of the ftp user, so the user can not access the bin/bash shell, just FTP commands.
- Create a password for this FTP user .
- Check the permissions that the user will have: I Mark: list, upload, download, append, make dir. And do not let the user exit your FTP directory (no up dir)
- Pass the password to your friend
- Click Activate to start The service
- Click on the Transfers tab to monitor the FTP transfers.
The files that you are receiving and the files you are sending should be in / var / ftp / click_here
Remember that FTP transmissions are not encrypted. So logins passwords can be intercepted over the network. A good policy is to change users and passwords for each new FTP session, change the control port on the modem / router, and only enable the FTP service when you transfer your files (upload / download).
Good transfers!
How to Setup a Home FTP Server – Part1
The growing interest in file sharing leads me to address the subject of a home FTP server.
Currently, with all the restrictions that file sharing is having, with RIAA lawsuits, MPAA lawsuits and internet service providers canceling accounts and blocking access, set up a home FTP server to exchange files with friends is almost a necessity. The advantage? It is a connection not promiscuous and has a high degree of confidence, since only known peers are connected. But first a little theory.
FTP (File Transfer Protocol)
File Transfer Protocol (FTP) is a standard network protocol used to copy a file from one host to another through a network based on TCP / IP, such as the Internet. FTP is built on a client-server connections and uses separate ports to control data between the client and server. The control connection is on port 21 and the data connection is on port 20, both on the server side. On the client side things change a little.
FTP users can authenticate via username and password, but can also log in anonymously, if the server is configured to allow this.
FTP passive and active
There are two modes of FTP: Active and Passive. The explanation on how they work is as follows.
Active FTP
In active mode FTP the client connects from a random unprivileged port (N > 1023) to the FTP server’s command port, port 21. Then, the client starts listening to port N+1 and sends the FTP command PORT N+1 to the FTP server. The server will then connect back to the client’s specified data port from its local data port, which is port 20.
From the server-side firewall’s standpoint, to support active mode FTP the following communication channels need to be opened:
- FTP server’s port 21 from anywhere (Client initiates connection)
- FTP server’s port 21 to ports > 1023 (Server responds to client’s control port)
- FTP server’s port 20 to ports > 1023 (Server initiates data connection to client’s data port)
- FTP server’s port 20 from ports > 1023 (Client sends ACKs to server’s data port)
When drawn out, the connection appears as follows:
Passive FTP
In passive mode FTP the client initiates both connections to the server, solving the problem of firewalls filtering the incoming data port connection to the client from the server. When opening an FTP connection, the client opens two random unprivileged ports locally (N > 1023 and N+1). The first port contacts the server on port 21, but instead of then issuing a PORT command and allowing the server to connect back to its data port, the client will issue the PASV command. The result of this is that the server then opens a random unprivileged port (P > 1023) and sends the PORT P command back to the client. The client then initiates the connection from port N+1 to port P on the server to transfer data.
From the server-side firewall’s standpoint, to support passive mode FTP the following communication channels need to be opened:
- FTP server’s port 21 from anywhere (Client initiates connection)
- FTP server’s port 21 to ports > 1023 (Server responds to client’s control port)
- FTP server’s ports > 1023 from anywhere (Client initiates data connection to random port specified by server)
- FTP server’s ports > 1023 to remote ports > 1023 (Server sends ACKs (and data) to client’s data port)
When drawn, a passive mode FTP connection looks like this:
Disadvantages of Active Mode
The main problem with active mode is: Since the request of ports is made on the client side, it becomes problematic for the firewall / NAT / Router to handle client requests.
In passive mode, since it is the server that determines which ports it will use, it is easier to set up the whole structure of firewall / NAT / Router.
Home FTP Server – Considerations
To successfully implement a home FTP server we need to consider what is the structure that we have.
Our server will be located on a machine behind a modem / router, in an internal LAN and communicating with the world through this modem / router.
As internet service providers block lower ports , <1024, we have to configure a NAT on the modem / router so that computers can access the external FTP control port (21) and the data ports.
The active mode is good enough for local networks, mainly behind a firewall / router, as the use of random ports will not harm the client connection.
But for connections through the Internet, you must use passive mode, which is much more configurable.
Of course, we also need an FTP server program, so we can perform the file transfer actions.
Well, after this brief introduction, the theory of what is FTP, we will cover how to set up the server and all the settings required for its proper functioning.
How To Connect MySQL with Open Office on Linux
To be able to combine the power of MySQL with the convenience of Open Office, opening a multitude of possibilities in Linux, you must connect MySQL with Open Office Base, the database application of Open Office.
There are several ways to do this, and I will illustrate one way that works effectively.
Connecting MySQL with Open Office Base – Existing Options
- You can connect Open Office Base with MySQL with JConnector, Java connector
- With a native extension of the Open Office, MySQL Connector for OpenOffice.org, but that only works with version 3.1 and has not been updated yet
- The ODBC connector, which was the best of the three.
Actually, I had no success with the JConnector and MySQL Connector extension is outdated and did not work with the current version of Open Office (3.2)
So we’ll see how to connect OpenOffice / MySQL with the ODBC connector.
ODBC connector
ODBC (acronym for Open Data Base Connectivity) is a standard software API specification for using database management systems (DBMS). ODBC is independent of programming language, database system and operating system.
ODBC was created by the SQL Access Group and first released in September, 1992. ODBC is based on the Call Level Interface (CLI) specifications from SQL, X/Open (now part of The Open Group), and the ISO/IEC.
The ODBC API is a library of ODBC functions that let ODBC-enabled applications connect to any database for which an ODBC driver is available, execute SQL statements, and retrieve results.
The goal of ODBC is to make it possible to access any data from any application, regardless of which database management system (DBMS) is handling the data. ODBC achieves this by inserting a middle layer called a database driver between an application and the DBMS. This layer translates the application’s data queries into commands that the DBMS understands.
ODBC Connector Installation on Linux
You need to install two packages for working with the ODBC connector on Linux, unixODBC package ( rpm version and deb version) and mysql-connector-odbc . Of course, if these packages are already in the repositories of your favorite distribution, the best thing to do is apt-get install package or yum / urpmi-i package. If not (as has happened with me) the solution is to download from the links provided above.
1. After the packages are installed, to test if they work ok, type $ odbcinst -j, which should list the current configuration options of the ODBC connector. Something like:
unixODBC 2.2.14
DRIVERS …………: / etc / odbcinst.ini
SYSTEM DATA SOURCES: / etc / odbc.ini
USER DATA SOURCES ..: / home / user / .odbc.ini
2. Now comes the important part: Set up the two files that will inform the Open Office Base how to communicate with MySQL. The files are odbcinst.ini and odbc.ini and are located in /etc
odbcinst.ini – This file will point out where are the drivers that will make the connection with the Open Office Base. This is the configuration that works in my distribution and installation. The names of the libraries and their locations may be different, but nothing that a whereis and locate can’t solve.
[MySQL]
Description = ODBC for MySQL
Driver = /usr/lib/libmyodbc5.so
Setup = /usr/lib/libodbcmyS.so.1
FileUsage = 1
3. odbc.ini
[MySQL-test] – Could be any name, this one was used only to illustrate
Description = MySQL BD_Teste
Driver = MySQL
Server = localhost – Here is the IP address of the MySQL server, in this example it is running on the local machine.
Socket = /var/lib/mysql/mysql.sock – The location of the MySQL socket must be declared, it is the one that will make the connection between the Open Office Base and MySQL
User = username – name of the registered user in MySQL, which will be used by Open Office Base to log into MySQL
Password = password – registered user password in MySQL, to allow Open Office Base logging into MySQL
Port = 3306 – This is the default port of MySQL
Database = test – PLEASE NOTE: Here’s the name of DATABASE in MySQL which we want to WORK with in Open Office Base . This database was previously created with any MySQL tool (Xampp, etc…)
Option = 3
ReadOnly = No – To allow Open Office Base to enter and modify data in the database
4. These were the steps in the Linux operating system. Now, the steps in Open Office Base
5. Database File> New
6. Click the Connect to a MySQL database and select the pulldown menu. Click Next.
7. In the next window, you should accept the default choice to connect using ODBC, and click Next.
8. Click Browse and select created connection ([MySQL test] should be listed in our case) and then click next.
9. then type go, do not register the database. Save the file. And from now on you can start working with your MySQL database within the Open Office Base.
Final Thoughts
The steps presented here work perfectly locally. To work in a network (a remote MySQL server) there are some changes, which we will see in the future. The odbc.ini file can be located in the default /home user, if one wants to change the configuration of the databases being accessed very often. In this case, the odbc.ini file that is in/etc should be blank, to avoid conflicts.
It should be noted that the names of the two libraries libmyodbc libodbcmyS may change, from a Linux distro to another, but they do the same thing, being necessary only to adapt the name to work in your preferred distro.
Load Balancing using the CUPS Print Queues
If you have more than 2-3 printers on a cups server, you can easily make the load balancing (pooling) of print jobs using CUPS print queues.
a) First, create a class of printers. Go to the CUPS web interface to make these configurations http://server-ip:631/ or http://localhost:631/ if you are logged into the CUPS server.
b) Select the class tab to create one class.
c) Select printers for this class.
d) Select this class as the default (Default). From now on, the print jobs will be distributed evenly among all the printers in the class, through print queues. The hint is that CUPS handles all the printers belonging to a class as if they were one, making automatically load balance between them.
Solving the Freeze Problem with APT-GET / Synaptic
Recently I experienced a problem with Synaptic / apt-get, and would like to share with you a simple way to solve this problem.
APT-GET – A Great idea
APT-GET is a very good tool for working with the installation of packages. There are others, more recent, but the robustness, reliability and ease of the apt-get tool gives it a prominent place in the major distros.
Born in the Debian distro, it has been ported to the RPM packages distros by brazilian now defunct company Conectiva(it merged with Mandrake and formed Mandriva).
The apt-get tool fetches the repositories for data lists on all packages of the distribution, and builds a database listing the packages, their dependencies, which new packages are in the repository, which are deprecated, and so on.
When you do an apt-get update or press the reload button in Synaptic, lists are downloaded from various repositories, and these lists are used to build a database that lists all packages.
Well, when there is a problem at that stage of the procedure, when the lists are being downloaded or the database is being built, it can ruin everything. And it happened to me.
At the time of creating the database, there was a corruption of files. Result: Neither apt-get worked nor Synaptic.
No Panic, the solution is simple
When this happened to me, I was worried because I was not seeing a solution: Synaptic and apt-get (command line) were frozen. Not working anymore.
I thought … Format and reinstall??
Then I started to research a little deeper on the apt-get and Synaptic (or any other graphical front end, Adept, aptitude, etc …).
And the solution is pretty simple. The steps I take here are for distros that use RPM packages, but the analogy can be done for deb based distros as well.
1. Look for the following directory /var/lib/rpm
2. In that directory will be the files of the database of apt-get/synaptic. The files have the following nomenclature __db.000 and so on. Depending on the size of the repos, there can be several files like this.
3. Then, delete all the __db files that exist in that directory. Of course you must be logged in as root. And, be very careful if you do rm-f. The ideal is to use a graphical file manager here, for you to see which files you are to delete and avoid any mistakes.
4. After deleting the __db files , type the following commands: # rpm -v –rebuilddb. This will rebuild the apt-get database.
5. If all goes well you can, from now on, use the command apt-get and its graphical front-ends with no problems. And, without having to reinstall your distro.
These tips are valid for RPM-based distros: Red Hat, Mandriva, CentOS, PCLinuxOS and Fedora. But, with the due adaptations, can be done on distros with deb packages as well.
How to make you own Linux distro
- Reconstructor (For distros based on Debian / Ubuntu)
- Suse Studio (For distros based on Open Suse, RPM package format)
- Slax (For distros based on Slackware)
- NimbleX (for distros based on Slackware)
- Linux From Scratch (Create a Linux distribution from scratch, and compile all packages)

- Load and store a project file: $ 0.02 per MB per month
- Create a project: $ 0.30
- Download a project: U.S. $ 0.45 per GB
- File Storage: $ 0.45 per GB per month
- Download: $ 0.35

- Live CD / DVDs
- VMware Image
- Hard Drive / USB image
- Xen image



[Quicky] How to get your Huawei USB modem to work on Ubuntu 10.04
sudo apt-get install udev-extras
gksu gedit /etc/udev/rules.d/15-huawei-e1550.rules
SUBSYSTEM==”usb”,
SYSFS{idProduct}==”1446″,
SYSFS{idVendor}==”12d1″,
RUN+=”/lib/udev/modem-modeswitch –vendor 0x12d1 –product 0x1446 –type option-zerocd”
lsusb -v
8 KILLER UBUNTU OTIMIZATION TIPS.
I have been using Ubuntu and open source software for some time and have discovered some few killer tricks to optimizing an Ubuntu system for speed and efficiency. This list is aimed at Ubuntu newbies and geeks alike.
1) Disable unessential services.
Services like Bluetooth may be running even if you don’t have the hardware installed.Go to Services window from the System>Administration menu. Be careful not to disable services you may rely on.
2)Monitor the CPU usage
Kill processes that are not essential but using up lots of resources. Go to System> Administration> System Monitor.
3)Trim the menu.
Lots of installed applications may make the Menu a bit “fat”. Trim it by right-clicking the Menu and deselecting Applications that you don’t use.
4)Add more work spaces.
If you use lots of applications and have your desktop cluttered, you may consider adding more work spaces to your desktop. Just right-click on the workspace area to see the Preferences window.
5)Move windows to work spaces.
You can press and hold Ctrl+ALT+
cursor left or right key to switch to a new work space.
If you hold down the Shift key, the active window will move to the new work space too.
6)Choose to remember running sessions when shutting down.
You can choose to let your system remember your last working session when you shut down to quickly launch into your working environment next time you power up. Just switch to Sessions Option and select “Automatically Remember.”
7)Add frequently used applications to the panel.
Add applications that you frequently use to the top panel for easy access.Just click the Menu and highlight which category you want then just drag the application you want to the panel.
8)Try XFCE
Gnome is nice and powerful but a bit cumbersome compared to XFCE, the default Xubuntu desktop. Search for the “Xubuntu-desktop” meta package in Synaptic.
Try these tips to optimize your sweet Ubuntu system and stay tuned for more. Please feel free to share your comment.