Welcome to Linux Screw! If you're new here, you may want to subscribe our RSS feed.
Question: I want to select APT repository server/mirror that is fastest for my location. How can I do it in Debian?
Answer: You can use application named as "netselect-apt" to get new sources.list file with fastest APT mirror. Install this application by command "sudo aptitude install netselect-apt" and run it in accordance with Debian distribution you use (Debian Etch in our example):
sudo netselect-apt -n etch -o /etc/apt/sources.list
sudo apt-get update
P.S. By the way, in Ubuntu you can do the same in a few clicks.
Share This
Question: I want to reset counters in /proc/net/dev (also shown in ifconfig output as RX and TX bytes) and thus I have to unload network interface driver. How to do it?
Answer: There are two commands in Linux CLI coming by default which would help to unload drivers: rmmod and modprobe. First of all it is necessary to find what kernel module controls certain NIC and then unload that module. For example, you have VIA VT6102 (RHINE-II) network card that is recognized by Linux as eth0 and want to disable its driver temporarily. Just execute the following:
"sudo rmmod via-rhine" or "sudo modprobe -r eth0" (or "sudo modprobe -r via-rhine"). You can use command dmesg to determine the name of kernel module you wish to unload.
Share This
Question: How can I restrict/allow access to certain service on timely basis with iptables? For example restrict access to SSH between 7:00 pm - 8:00 am on weekdays?
Answer: You are welcome to use iptables patch-o-matic extension (pom or p-o-m) that allows you to match a packet based on its arrival or departure (for locally generated packets) timestamp. The syntax is the following:
iptables RULE -m time --timestart TIME --timestop TIME --days DAYS -j ACTION
Where:
--timestart TIME: Time start value (format is 00:00-23:59)
--timestop TIME: Time stop value (the same format)
--days DAYS: a list of days to apply, from (format: Mon, Tue, Wed, Thu, Fri, Sat, Sun).
To add the rule stated in the question use the following command:
iptables -A INPUT -p tcp -d 192.168.0.1 --dport 22 -m time --timestart 19:00 --timestop 8:00 -days Mon,Tue,Wed,Thu,Fri -j DROP
Hope it helps!
Share This
Question: How can I get information about hardware manufacturer, model name, serial number, BIOS information using Linux command line (CLI)?
Answer: You are welcome to use dmidecode which helps to get information about your system’s hardware as described in your system BIOS. That information typically includes system manufacturer, model name, serial number, BIOS version, asset tag as well as a lot of other details depending on the manufacturer.
Beware that DMI data have proven to be too unreliable to be blindly trusted. Dmidecode does not scan your hardware, it only reports what the BIOS told it to. Dmidecode was first written by Alan Cox and is now being further developed and maintained by Jean Delvare. It is released under the General Public License (GPL).
This tool can be easily downloaded from here (source code) or can be installed as binary package included into repositories of many distributions like Debian, Ubuntu, Gentoo. FreeBSD version is also available. Actualy it is reported that dmidecode works well on the following systems:
- Linux i386
- Linux x86_64
- Linux ia64
- FreeBSD i386
- FreeBSD x86_64
- NetBSD i386
- OpenBSD i386
- BeOS i386
- Cygwin i386
- Solaris x86 (CVS version)
In Ubuntu (my favourite distro) just execute the following: sudo aptitude install dmidecode (sample output is here).
Share This
Static routing is the term used to refer to the manual method used to set up routing. An administrator enters routes into the router using configuration commands. This method has the advantage of being predictable, and simple to set up. It is easy to manage in small networks but does not scale well.
Question: How can I save static routes I set up in my Fedora/RedHat/CentOS Linux after I reboot server?
Answer: In Fedora Linux (or RedHat, CentOS) you can set up static routes for certain network interface (for example eth1) by editing file /etc/sysconfig/network-scripts/route-eth1.
For example, you have to save static route added by the following command:
route add -net 192.168.0.0 netmask 255.255.255.0 gw 192.168.100.1 dev eth1
To do it, just add the following line to /etc/sysconfig/network-scripts/route-eth1:
ADDRESS0=192.168.0.0
NETMASK0=255.255.255.0
GATEWAY0=192.168.100.1
Share This
Date: August 16, 2007. Categories:
faq and tips.
Question: I forgot root password for MySQL DBE. How to reset or recover it? PLEASE HELP!
Answer: Below is simple algorithm to reset MySQL root password in Linux, FreeBSD, OpenBSD and other Unix like operating systems:
1. Stop MySQL server process by one of the following commands:
# /etc/init.d/mysqld stop
# killall -9 mysqld
# kill `cat /mysql-data-directory/host_name.pid`
# mysqladmin shutdown
To check if mysqld is killed run "ps ax | grep mysqld" that should show no mysqld instances.
2. Start MySQL server without password protection:
$ mysqld --skip-grant-tables --user=root &
or
$ mysqld --skip-grant-tables &
3. Login to MySQL console by "mysql -u root" and set up new password with the following mysql commands:
mysql> UPDATE mysql.user SET Password=PASSWORD('newpassword') WHERE User='root';
mysql> FLUSH PRIVILEGES;
4. Now you should be able to connect MySQL with new password.
P.S. There is alternative 2 and 3 steps:
2. Create text file /tmp/init.mysql with the following contents:
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpassword');
3. Start MySQL with command:
# mysqld_safe --init-file=~/mysql-init &
Hope it helps!!!
Share This
Recent Ideas