Random tips

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

jiml8

Thread Starter
Guest
Joined
Jul 2, 2005
Messages
2,634
I maintain a file that I call "Jims_Howtos", which contains random tips. I've done this for more than a decade now and the file is fairly good sized and not at all organized.

Usually the tips are things I had to figure out, but don't do often enough to really master it. So I write down what I learned in this file and when next I need to do this, maybe two years from now, I can find it in the file rather than figuring it out again. I also keep long command strings here; far easier to do that than to reconstruct them when I need them.

So, here's some random Linux tips that I think are generally useful, with no organization and in no order.

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

Example how to batch delete a number of directories within a directory when those all have similar names, while not deleting some of them based upon some criteria or other. This particular string deletes all directories that start with the name gpg but excludes those whose datestamp is 2010-09. Start within the parent directory.

ls -al | grep gpg | grep -v 2010-09 | tr -s '[:blank:]' '\t' | cut -f 8 | xargs rm -rf

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

When you take a whole disk image it is sometimes necessary to mount a partition that is within that image. To do this, you must find it, attach it to a loop device, and mount it.

Find the partitions in the image:

parted imagename.iso unit b print

Choose the desired partition and assign it to an available loop device:

losetup -o<starting byte of partition from previous command> /dev/loopN imagename.iso

Then mount it:

mount /dev/loopN mountpoint

Later, unmount it and release the loop device:

losetup -d /dev/loopN

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

This next tip will save you having to do a complete reinstall if you make a major hardware change, such as changing drive technology from PATA to SATA or some such. I've actually had to do it twice in the last 6 weeks on two different systems.

To create new initrd while working from a Linux Live CD (for instance, hardware change means driver change)

mount the system partition (/dev/sda1) someplace convenient, perhaps on /mnt.
chroot to the system partition
make sure /tmp and /var/cache are available. If not, mount them.
mount /sys using: mount sysfs -t sysfs /sys
mount /proc using: mount proc -t proc /proc
Now cd to /boot and run mkinitrd

It may also be necessary to bind /dev. If so, prior to the chroot, enter this command:
mount -o bind /dev /mnt/dev

where /mnt/dev is the dev directory on the system partition you will be chrooting to.
---------------------------------------------------------------------------------------------------------------------------------------

you can get a running kernel's configuration by zcat /proc/config.gz
-------------------------------------------------------------------------------------------------------------------------------------

ldd command specifies library dependencies needed by an executable. So when there is a permissions problem that causes prog to fail, ldd `which prog` lists library dependencies. You can then check each lib for proper permissions.


--------------------------------------------------------------------------------------------------------------------------------
Capture every keystroke:

od -tx1 /dev/input/event0

This gives 16 bytes of data for every event (key down, key up, etc).

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

Start a movie on another machine. SSH in then execute one of these:

mplayer -v -display :0 myvideo.avi

will work if you have one video card. If you have more than one card, then something like this might be needed:

mplayer -v -adapter 0 -display :0 myvideo.avi

This command will start it fullscreen on the default display:

mplayer -fs -v -display :0 myvideo.avi

------------------------------------------------------------------------------------------------------------------------------------------
To monitor system and file calls of a program, start it with strace myprog.

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

Access POP account using Telnet

Try this:

Open a command window and type in "telnet pop.fnbcnet.com 110"

If the server gives you some string that indicates a connection (something like this):

+OK POP3 server ready <[email protected]>

, then type in this:

USER (yourusername)

server responds

+OK

then you enter this:

PASS (your password)

server responds:

+OK

So, if you get this prompt after entering your password, then type this:

list

This should give you a list of the emails in the queue, listed sequentially.

If this works, then this demonstrates that there is a configuration error in your client (which probably is Outlook Express from the error message). If it doesn't work then either you don't have the telnet command (it should be there on pretty much any windows installation) or there is some problem on your ISP's side.

While you are at it, if you wish to read your email, you can do so. Type, for instance,

top 2 35

and you can read the first 35 lines of the second email in the queue.

type, for instance,

dele 2

to mark the second email in the queue for deletion. The actual deletion won't occur until you quit the POP server

To reset the queue, so that messages marked for deletion are unmarked, type :

rset

You can retrieve the entire message:

retr 3

will cause the server to send the third message to you
When you are finished, type "Quit".
---------------------------------------------------------------------------------------------------------------------------------------
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top