Linux-General

From 123developers

Jump to: navigation, search

Contents

Linux General FAQ

How Do I Format Man Pages without man or groff?

ANS: The man2html program translates groff text to HTML, which you can view with a Web browser. The man2html program, and many like it, are availble on the Web. Look for them with your favorite search engine.The unformatted manual pages are stored in subdirectories of /usr/man, /usr/local/man, and elsewhere.

If you want to view text, use nroff and less. Both of these programs have MSDOS versions with an implementation of the man macro package available as well. An example would be:

$ nroff -man /usr/man/man1/ls.1 | less 

How To Scroll Backwards in Text Mode

ANS: With the default US keymap, you can use Shift with the PgUp and PgDn keys. (The gray ones, not the ones on the numeric keypad.) With other keymaps, look in /usr/lib/keytables. You can remap the ScrollUp and ScrollDown keys to be whatever you like.

Recent kernels that have the VGA Console driver can use dramatically more memory for scrollback, provided that the video card can actually handle 64 kb of video memory. Add the line:

 #define VGA_CAN_DO_64B 

How To Get NUM LOCK to Default to On

ANS: Use the setleds program, for example (in /etc/rc.local or one of the /etc/rc.d/* files)

 for t in 1 2 3 4 5 6 7 8
 do
   setleds +num < /dev/tty$t > /dev/null
 done

How To Set (Or Reset) Initial Terminal Colors

ANS: The following shell script should work for VGA consoles:

 for n in 1 2 4 5 6 7 8;
 do
   setterm -fore yellow -bold on -back blue -store > /dev/tty$n
 done

How Do I Make a Shared Library?

ANS: For ELF,

 $ gcc -fPIC -c *.c
 $ gcc -shared -Wl,-soname,libfoo.so.1 -o libfoo.so.1.0 *.o

What's This Huge Security Hole in rm!?

ANS: No there isn't. You are obviously new to unices and need to read a good book to find out how things work. Clue: the ability to delete files depends on permission to write in that directory.

Why Don't lpr and/or lpd Work?

ANS: First make sure that your /dev/lp* port is correctly configured. Its IRQ (if any) and port address need to match the settings on the printer card. You should be able to dump a file directly to the printer:

$ cat the_file >/dev/lp1

Is There a Defragmenter for Ext2fs?

ANS: Yes. There is defrag, a Linux file system defragmenter for ext2, Minix, and old-style ext file systems. It is available at ftp://metalab.unc.edu/pub/Linux/system/filesystems/defrag-0.70.tar.gz. Users of the ext2 file system can probably do without defrag, because ext2 contains extra code to keep fragmentation reduced even in very full file systems

How To Determine What Packages Are Installed on a System

ANS: For distributions that use RPM format packages, use the command:

rpm -qa 

ANS: For distributions that use DEB format packages,use the command:

dpkg -l

How to get the System Information

uname -a

The output looks like this

Linux backup.aou.com 2.6.18-128.1.10.el5 #1 SMP Thu May 7 10:35:59 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux 

How to Edit /etc/passwd

vipw

Release DHCP

dhclient

HowTo View the contents of an archieve

tar -tf content_view.tar.gz 

HowTo split a large file into smaller ones of required sizes

split -b 3m php-5.2.6.tar.gz php

HowTo Join the Splitted files

cat php_a* > php-5.2.6.tar.gz

HowTo search for a particular word and delete it

find / -name aaa* -delete

HowTodelete the last 30 days files. For files before 30 days +30

find /root/wallpapers/ -mtime -30 | xargs /bin/rm -f

HowTo get the MAC of all systems in the network 192.16.1.0

nmap -sP 192.168.1.*

HowTo burn a cd image to CD

cdrecord -v speed=20 dev=/dev/scd0 /root/pfSense-1.2-RC3-LiveCDInstaller.iso

HowTo Make ISO of a directory

mkisofs -r -o /tmp/var-www-disk1.iso /var/www

HowTo Administer MySQL from Commandline

HowTo Create a Database

mysql -e "create database vpopmail" -ppassword

HowTo Show Database list

mysql -e "show databases" 

HowTo get password status of the user account

passwd -S someuser

HowTo Lock an Account

passwd -l someuser

HowTo free memory when memory is in short

memhog 500m

HowTo stop all process except your shell

kill 0

HowTo kill system beep

rmmod pcspkr

HowTo query the contents of rpm package

rpm -qpil sendmail-8.14.1-4.2.fc8.i386.rpm

HowTo get Harddisk Information

 hdparm -I /dev/sda 

HowTo to view a file without Commented Lines

 cat /etc/squid/squid.conf | grep -v ^# | grep -v ^$

HowTo add TimeStamp with Commandline History

export HISTTIMEFORMAT="%F %T "

Then Add the following to make it permanent