Archive for the ‘Linux’ Category

Adding a directory to your $PATH

Posted in Linux  by kissdeath on June 13th, 2009

In the Linux operating system the $PATH is a listing of all directories where the system will look for commands. What this means is that all of the commands located in the directories included in your path will be globally executable. For example: The /usr/bin directory contains quite a lot of commands that can be excuted from within any directory on your system. Because of this you can issue the ls command from within any directory and get the listing of the contents of that directory. If the ls command wasn’t in a directory in your path you would have to include the explicite path to that command (i.e. /usr/bin/ls).

As a Linux user you can add directories to your $PATH. This is helpful when you don’t want to add a command to a directory in your $PATH but you want that command to be globally executable. Doing this is actually quite easy.

What is currently in your $PATH?

NOTE: This article applies only when you are using the Bash shell. To find out what directories are included in your current $PATH issue the command:

echo $PATH

You should see something like:

/usr/lib/qt-3.3/bin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/jlwallen/bin

Notice the /opt directory is missing. Often the /opt directory is a great place to “install” other applications for global use. But if this directory is not in your $PATH, you will always have to use the explicit path to call a command. With that in mind let’s add /opt.

.bash_profile

In order to add a directory you have to edit a file in your ~/ (home) directory. The .bash_profile file determines user specific environment and start up programs. This file also checks for a .bashrc file for aliases and functions, but that has nothing to do with your $PATH.

There is one particular line you need to examine in your .bash_profile:

PATH=$PATH:$HOME/bin

This is the line that determines anything extra in your $PATH. As you can see, in the example above, the extra directory added to the users’ $PATH is the ~/bin directory. Of course in most distributions this isn’t used (or even created during installation). Why ~/bin is still included I do not know. In order to add another directory to your $PATH in this line you would seperate the directories with a “:”. To add the /opt directory that line would now look like:

PATH=$PATH:$HOME/bin:/opt

As you can see the /opt directory has been added proceeding a “:”. Complete this addition and save the file. You’re not done yet.

If you issue the command echo $PATH you will still not see /opt in the users’ $PATH. Why? You have to log out and log back in before this change will take effect. So log out, log back in, and issue the command again. Issuing the command echo $PATH will not issue:

/usr/lib/qt-3.3/bin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/jlwallen/bin:/opt

Any command found in the /opt directory is now global.

Final thoughts

The $PATH is a very powerful tool to take advantage of in Linux. By using it you can install applications in directories outside of the norm and still make them global. I often install applications in the /opt directory or will create a /data directory for a more temporary application installation.

Source.

How to configure network interfaces configuration files in Linux?

Posted in Linux  by kissdeath on June 2nd, 2009

by fujisai

Vấn đề này chưa xong vấn đề kia đã ùn ùn kéo tới … haizz, dùng Linux là thế đấy. Hôm nay tôi xin viết một bài nhỏ hướng dẫn một chút về một trong những “vấn đề” cơ bản trong khi sử dụng Linux. Đó là cấu hình “card mạng” của máy tính sử dụng Linux thông qua file config.

Mọi người dùng Linux chắc hẳn đều biết mọi cấu hình trong Linux nói chung đều có thể được nhúng tay vào chỉnh sửa trong một hoặc vài file cấu hình nào đó. Nếu chưa dùng hoặc dùng Linux chưa quen bạn sẽ nói ngay rằng làm thế thật là phức tạp, nhưng nếu dùng nhiều bạn sẽ phát hiện ra rằng cách đó không hề tồi  , nói cũng rất nhanh mà còn làm cho bạn hiểu rõ hơn về cái bạn đang làm việc. Mà nhất là khi một ngày đẹp trời nào đó thành phần đồ họa trong Linux của bạn có vấn đề chẳng hạn.

“Ngày đẹp trời” đó đến với tôi khi tôi chợt phát hiện ra (hoặc nhớ ra, vì rõ ràng tôi cũng dùng cái máy đó từ lâu rồi, và cũng phải cấu hình mạng cho nó rồi  ) cái CentOS tôi đang dùng không hỗ trợ lệnh netconfig rất tiện mà hồi trước tôi hay dùng với RHEL4. Vậy là tôi buộc phải động tới file cấu hình của card mạng

Đại loại các bước sẽ như thế này:

1. Tìm  file cấu hình card mạng

- Đối với RHEL/CentOS/Fedora: mỗi card mạng sẽ có một file với đường dẫn dạng:

/etc/sysconfig/network-scripts/ifcfg-<interface_name>

ở đây interface_name là tên của card mạng trong máy bạn, thường thì nếu máy bạn có 1 card mạng ethernet nó sẽ là eth0.

- Đối với Debian/Ubuntu: tất cả các card mạng trong máy được cấu hình trong cùng một file tại đường dẫn:

/etc/network/interfaces

2. Xác định hình thức cấp IP và sửa file cấu hình theo hình thức đã chọn

- Nếu là DHCP:

+ RHEL/CentOS/Fedora: sửa file thấy bên trên kia thành

DEVICE=eth0
ONBOOT=yes
BOOTPROTO=dhcp

+ Debian/Ubuntu: thêm vào file trên kia một đoạn như sau

auto eth0
iface eth0 inet dhcp

- Nếu là static IP:

+ RHEL/CentOS/Fedora: sửa file thấy bên trên kia thành dạng như sau

DEVICE=eth0
BOOTPROTO=static
IPADDR=XXX.XXX.XXX.XXX
NETMASK=255.255.255.0
GATEWAY=XXX.XXX.XXX.XXX
ONBOOT=yes

+ Debian/Ubuntu: thêm vào file trên kia một đoạn như sau

auto eth0
iface eth0 inet static
address 208.88.34.106
netmask 255.255.255.248
broadcast 208.88.34.111
network 208.88.34.104
gateway 208.88.34.110

Các trường trong các file trên nói chung là dễ hiểu, còn nếu bạn muốn tìm hiểu kỹ thì hãy tham khảo links được đưa phía cuối bài viết!

3. Thêm vào cấu hình DNS (làm bước này nếu ở bước số 2 bạn chọn Static IP)

- Tìm file /etc/resolv.conf

- Sửa file này bằng việc thêm vào dòng:

nameserver XXX.XXX.XXX.XXXIP address of primary name server
nameserver XXX.XXX.XXX.XXX - IP address of secondary name serve

4. Restart dịch vụ mạng để máy tính nhận lại cấu hình

- RHEL/CentOS/Fedora: có thể dùng một trong hai cách

+ service network restart

+ /etc/init.d/network restart

- Debian/Ubuntu: sudo /etc/init.d/networking restart

Đến đây nhìn chung là bạn đã có thể sử dụng được network rồi  . Chúc mừng!!!

Còn nếu có vấn đề gì, hoặc cần tìm hiểu thêm về các trường xuất hiện trong các file cấu hình kia, bạn có thể tham khảo tại địa chỉ:

http://www.yolinux.com/TUTORIALS/LinuxTutorialNetworking.html#CONFIGFILES

http://www.redhat.com/docs/manuals/linux/RHL-8.0-Manual/ref-guide/s1-networkscripts-interfaces.html

Source.

Where do I find Linux software?

Posted in Linux, Tips-Thủ thuật  by kissdeath on April 25th, 2009

If you are a Windows user you most likely know where to get software. You can either go to your local software retailer or you can go to a place like downloads.com. But what if you are searching for Linux software? Where do you go? Is there a one stop shop for all of your software needs? Yes and no. Even though that answer is not a resounding YES! there is a plus side – there are tons of software titles to have with Linux. But without knowing where to look, the downside is you might not even know that software exists.

With that in mind I am going to point out some of the best ways (and places) to find software for the Linux operating system. Some of these might be all too obvious. Some may not. We’ll start with the obvious.

Read the rest of this entry »

The best Linux media players

Posted in Linux, Softwares  by kissdeath on April 25th, 2009

Recently I have had a lot of people asking how to play various media files in Linux. Since most users are migrating over from either Mac or Windows, they are either used to one single application handling their media files or at least knowing exactly what apps handle each media type. When they migrate over all of a sudden there is no Windows Media Player or iTunes. And then comes the bombardment of different applications to choose from! All of this combined makes for some difficult usage.

Read the rest of this entry »

Set up a reliable ftp server with proftpd

Posted in English Articles, Linux  by kissdeath on April 25th, 2009

If you have a need for an ftp server, and you have a Linux machine on your network, then you need look no further than proftpd. The proftpd project came about to fill the need for a secure and reliable ftp server for the Linux operating system. Proftpd uses a single configuration file, so it’s simple to set up. This ftp server was also based on an admiration for Apache, so there are many similarities between the two. For instance, where Apache uses .htaccess, proftpd uses .ftpaccess for per-directory configuration.Proftpd also support anonymous ftp access and can be run as a stand alone server or using inetd control.

The aim of this article is to show you how to quickly set up an ftp server for user access and anonymous access on your Linux server.

Read the rest of this entry »