• Home
  • About Me
  • Welcome to Short Linux hints
Short hints about Linux


  • Tags

    hacking Linux linux cpanel courier maildir mailbox exim security viruses worms
  • Blogroll

    • Geany
    • Handy one-liners for sed
    • Linux By Example
    • Penguin Tutor

Oct 14

Having fun with /dev/console

LPI Comments Off

While wondering how to direct output to my console I come upon a funny thing. Under Ubuntu 8.04.1 try sudo cat /dev/console and just watch (if you can) :) I know it is stupid but this is just another outdated thing which is questioned in the current LPI exam :)

Anyway, according to some sources output directed to /dev/console should be shown on the xconsole session :) This should be especially useful when debugging applications. Presumably, if you know the facility and the priority of the debugging messages, you could direct them through syslog to the console.

Oct 12

LPIC-1 (LPI 102) Syslog Cheatsheet

LPI Comments Off

It is very probable that each LPIC-1 102 exam contains a twisted question about the neglected syslog.

Here are some configuration options taken from 'man syslog' to get us pass through:

mail.*;mail.!=info       /var/log/mail - this means that all messages from the mail facility with any priority but 'info' will be logged in the file /var/log/mail

news.info;news.!crit     /var/log/news - all messages from news.info (including) to  news.crit  (excluding)  would be logged to the /var/log/news file.

mail.!debug - putting only this on a line means to skipp all mail messages but the ones for debugging

*.*            @example.org - this means to redirect all messages to example.org

kern.=debug              |/usr/adm/debug - route only kernel debugging messages to the debug pipe

Oct 12

LPIC-1 102 Documentation Cheatsheet

LPI Comments Off

man -aw [subject] - shows the files corresponding to all entries for a subject.
man -k = apropos - searchs name and detail description
man -f = whatis - searches one line summaries

Man sections
1   Executable programs or shell commands
2   System calls (functions provided by the kernel)
3   Library calls (functions within program libraries)
4   Special files (usually found in /dev)
5   File formats and conventions eg /etc/passwd
6   Games
7   Miscellaneous (including macro  packages  and  conventions), e.g. man(7), groff(7)
8   System administration commands (usually only for root)

Man searches the $MANPATH for its entries. Usually these entries are stored in gz format in /usr/man/ (or /usr/share/man/). Uses the $PAGER variable to present the output.

/etc/issue - shows text on console when you log in locally
/etc/issue.net - shows text on console when you log in remotely
/etc/motd - moto of the day - displays on all logins

You can search for help online (stupid):

- The linux documentation project
- Online guides
- Vendor sites
- Mailing lists

Oct 12

LPIC-1 102 Printing Cheatsheet

LPI Comments Off

One of the most unpleasant topics in LPIC-1 (LPI 102) is the one about printing. That's why I have prepared the following must-know cheatsheet about the exam.

/etc/printcap - the file which describes the available printers and their options. Used by the main spooling daemon. Important options:

if=input_filter
lp=printer_device
lf=log_file
mx=max_size
sd=spool_directory

/var/spool/lpd/lpi - the spooling directory for a sample printer called 'lpi'. It contains all the queued print jobs and control files for the lpi printer.

lpq [Options] [Users] [job id]

# lpq -Plpi - show the queued jobs for the lpi printer

lprm [-Pprinter name] [users] [job id] - remove printer jobs

lpc [command] [printer name] [job id] - printing control

# lpc help
Commands may be abbreviated.  Commands are:
abort   enable  disable help    restart status  topq    ?
clean   exit    down    quit    start   stop    up

# lpc topq lpi 102 - move print job 102 to the top of the queue for the lpi printer

# lpc disable lpi - disallow new jobs to be queued for the lpi printer. Allow the ones already queued to be completed.

Here is the ultimate printing command 'lpr -Plpi -J "LPI test print" -#2 -m -p -q -r lpi.txt' - this means to use the printer lpi, to name the job "LPI test print", to make 2 copies of it, send mail upon completion, to make it in Pretty format, to queue it for later and finali to remove the file when done.

lpstat -s = lpstat -d -c -v - Display default printer, all available printers and classes

lpstat -p = lpc status - check printers' statuses

Use cupsenable and cupsdisable to enable and disable a printer.

# lp -i 16 -n 5 - change the number of copies to 5 for job id 16

Filters are used to convert generic data to printable data:
Raw data -> Post Script (PDL format) -> Ghost Script (Printer specific data) -> Printer

To use a Samba printer you need to:
1. use smbprint input filter
2. Have a .config file with in the spool directory defining server, service and password.

CUPS uses MIME types to determine the correct filter for a file.

lpadmin -x [printer name / printer class] - deletes a printer / class.

A printer class is responsible for properly distributing the jobs to a group of printers.

Oct 06

More LPI 102 Stuff

LPI Comments Off

While making tests from http://www.penguintutor.com/cgi-bin/quiz/index.pl?&style=default (an excellent resource for preparing for the exam) I have come upon a few mistakes. Here is one of them:

---------------------------------------------------------------------------------------

Name: passer        Question: 21 / 25

Ref No: linuxquiz_0047

Which line below could be a valid line in the /etc/group file? The users: john, stewart and fred should all be members of the finance group. Select the most appropriate answer.

finance:x:503:john,stewart,fred

503:finance:x:john,stewart,fred

finance:503:x:john,stewart,fred

john,stewart,fred:finance:x:503


Incorrect

Your answer:

finance:x:503:john,stewart,fred

Correct answer:

The correct answer is finance:503:x:john¸stewart¸fred.

Well, this is obviously wrong :) My answer is the correct one :) Here is a great reference from one of my favorite Linux sites:

http://www.cyberciti.biz/faq/understanding-etcgroup-file/

---------------------------------------------------------------------------------------

You might also wonder what means 'quaded decimal netmask in CIDR notation'. If you just take a look at 192.168.0.22/24, it is what /24 stands for :) Subnetting is more likely the term you are acquainted with and you could easily recall the basic rules from the following chart taken from Wikipedia:

Subnetting

Subnetting

---------------------------------------------------------------------------------------

Another thing that really bothers me is that there is no 'breakfast' time for the 'at' command while there is 'teatime'. This command does take some funky input :)

---------------------------------------------------------------------------------------
Also, there is one less popular file called /etc/sysconfig/network. I just wonder how could I have missed it until now :) I guess that's one thing 'setup' changes automatically for you:

NETWORKING=yes
FORWARD_IPV4=yes
HOSTNAME=linux.bgsnow.com
GATEWAY=192.168.0.1
GATEWAYDEV= eth3

---------------------------------------------------------------------------------------

Playing with logger :) This is another simple program which logs messages to the default syslog file. For example, on my box:

terry@:~$ logger
zaaeeeebi
i am the biggest hacker in the world :)

terry@:~$

on my other console:

terry@:~$ tail -f /var/log/messages
Oct  6 19:39:41 a2 -- MARK --
Oct  6 19:45:16 a2 kernel: [ 5171.047451] gnome-screensav[593]: segfault at 00000200 eip b7f4cb9d esp bfe87d90 error 4
Oct  6 19:59:41 a2 -- MARK --
Oct  6 20:19:41 a2 -- MARK --
Oct  6 20:39:41 a2 -- MARK --
Oct  6 20:59:41 a2 -- MARK --
Oct  6 21:19:41 a2 -- MARK --
Oct  6 21:39:41 a2 -- MARK --
Oct  6 21:59:41 a2 -- MARK --
Oct  6 22:17:16 a2 terry: asdasd
Oct  6 22:18:11 a2 terry: zaaeeeebi
Oct  6 22:18:20 a2 terry: i am the biggest hacker in the world :)
Oct  6 22:18:20 a2 terry:

terry@:~$

Probably logger is not the command you are going to use every day but it seems to be quite popular for the LPI 102 exam. Googling for it will render endless number of irrelevant results so you better check its man page.

---------------------------------------------------------------------------------------

Freaking admins with shutdown -k

I guess the inventor of shutdown has a good sense of humor and wants to provide an easy way for the community to freak admins by sending bogus shutdown messages :) When you have a new admin, make sure he / she is logged on a system and issue:

root@a2:/home/terry# shutdown -k 1 u suck and i 0wn u, little tward. everything is deleted and shutting down!

Broadcast message from terry@a2
(/dev/pts/1) at 22:43 ...

The system is going down for maintenance IN ONE MINUTE!
u suck and i 0wn u, little tward. system is deleted and shutting down!
root@a2:/home/terry#

This is the so called psychological training for new guys to get used to the rough reality :) It may also help you pass the LPI exam and answer the twisted questions about the shutdown command :)))

---------------------------------------------------------------------------------------

Now another funny thing - the well know init command has an option to reload its configuration (don't tell me you haven't reloaded the init configuration without rebouting). It is taken again from PenguinTutor:

Ref No: linuxquiz_0028

What command is used to reload the /etc/inittab file after it has been updated? Choose the most appropriate answer:

/sbin/init q

/sbin/init r

/sbin/init s

/sbin/init 6


Not Answered

Your answer:

No answer

Correct answer:

The correct command is /sbin/init q. The r option is not a valid option for the init command. The s option will change to single user mode, and the 6 option will reboot the system. The option q is the most appropriate as it reloads the configuration file without rebooting the server.

One thing is that according to the only documentation I find 'q' is for quite, suppressing the errors...

oot@a2:/home/terry# init --help
Usage: init [OPTION]...
Process management daemon.

Options:
-q, --quiet                 reduce output to errors only
-v, --verbose               increase output to include informational messages
--help                  display this help and exit
--version               output version information and exit

This daemon is normally executed by the kernel and given process id 1 to denote its special status.  When executed by a user process, it will actually run
/sbin/telinit.

Report bugs to <upstart-devel@lists.ubuntu.com>

Another funny thing is that there are many other undocumented options such as:

root@a2:/home/terry# init a
root@a2:/home/terry# init b
root@a2:/home/terry# init c
root@a2:/home/terry# init d
init: illegal runlevel: d
Try `init --help' for more information.

If you guessed that a, b and c (just like q) did nothing, you guessed it right :) I hope there is no such a stupid question on the exam :)

---------------------------------------------------------------------------------------

Previous Entries
Powered by WordPress .::. Designed by SiteGround Web Hosting

cssandhtml