User Tools

Site Tools


linux:commands

Commands that usually I forget

Restart DNS (Flush DNS Cache in Suse)

service nscd restart

Users management for HTTP access (Suse)

Suse version, but I guess it's similar for other distributions.
In the example below, the file that contains the users (including encrypted passwords and information such as name, email, etc..) in htpasswd.users.
If username does not exist it's created, otherwise it's updated.
The command requests the password for username.

Nagios related example:

htpasswd2 /usr/local/nagios/etc/htpasswd.users username

Change Owner

Use the chown command to change owner to one or many files. The example below change the owner of folder my_folder to wwwrun user and www group.
The -R parameter (recurring) analyzes all subfolders and files changing the owner and group as above.

chown -R wwwrun:www /srv/www/htdocs/my_folder

Search for installed Package

RedHat, Fedora Core, Suse Linux, CentoOs distribution

Use rpm command as follows to list all installed packages

rpm -qa
rpm -qa | grep 'package-name'
rpm -qa | grep -i '*httpd*'

Debian or Ubuntu Linux distribution

You can use dpkg command to list all installed packages:

dpkg --list
dpkg --list | grep 'package-name'
dpkg --list | grep -i '*php*'

Redirect standard output to a PC

If a command has a graphical output (like yast2) and the server has no display (or you are remotly connected via terminal emulator), it's possible to redirect the output to a different PC using the command export.
The PC must run a listener, such as Xmanager. Command example:

Format:    export DISPLAY=ip_address:0.0

Example:   export DISPLAY=172.28.9.231:0.0

Set Proxy authetication

To manually set the proxy with authentication, use the format:

Acquire::http::proxy "http://user:password@proxy_server:port/";

For example, to set the proxy for apt-get in Ubuntu, change the configuration file /etc/apt/apt.conf:

Acquire::http::proxy "http://user:password@my_proxy:8080/";
Acquire::ftp::proxy "ftp://user:password@my_proxy:8080/";
Acquire::https::proxy "https://user:password@my_proxy:8080/";

Set SMTP server (SUSE)

In file /etc/postfix/main.cf add/update the key:

relayhost = my_SMTP_server.my_domain

Up Ethernet Interface (SUSE)

First get the interface name with the command ifconfig:

ifconfig
eth0      Link encap:Ethernet  HWaddr 00:50:56:B1:00:2A
          inet addr:172.28.9.87  Bcast:172.28.15.255  Mask:255.255.248.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:9756009 errors:0 dropped:0 overruns:0 frame:0
          TX packets:53735102 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:902184895 (860.3 Mb)  TX bytes:79080496538 (75417.0 Mb)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:16662619 errors:0 dropped:0 overruns:0 frame:0
          TX packets:16662619 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:8355092362 (7968.0 Mb)  TX bytes:8355092362 (7968.0 Mb)

Then use the ifup command:

ifup eth0
linux/commands.txt · Last modified: 2013/07/11 23:08 by IperCube