domingo, 4 de março de 2012

Linux: Find Dell Service Tag

Type the following command to find out Dell service tag:
# dmidecode | grep -i serial

OR
# dmidecode -t 1

The following command will only display service tag:
# dmidecode -s system-serial-number

Referência: Red Hat / CentOS Command To Find Dell Service Tag

Linux: Locking/Unlocking An Account

Task: Linux Locking an Account

The syntax is as follows:
# passwd -l {username}

The -l option disables an account by changing the password to a value which matches no possible encrypted value. In this example, lock user account named vivek. First, login as a root user and type the following command:
# passwd -l vivek

Task: Linux Unlocking an Account

The syntax is as follows:
# passwd -u {username}

The -u option re-enables an account by changing the password back to its previous value i.e. to value before using -l option. To unlock user account named vivek. Login as a root user and type following command:
# passwd -u vivek

Referência: Linux Locking An Account

Linux: Find Out Maximum RAM Supported By The Server BIOS / Motherboard

Most modern server supports 16GB, 32GB, 64GB or more RAM and has 4 or more DIMM slots. To find out what is the maximum system can support type the following command as root user:
# dmidecode -t 16

You can find out currently installed memory information (DIMM and its slots) by typing the following command:
# dmidecode -t 17

Referência: Linux / Unix: Find Out Maximum RAM Supported By The Server BIOS / Motherboard

Shell: Cat Command Examples

To create a file called "foo.txt", enter:
cat >foo.txt
Unix is the best.
<control-D>

You can combine two files and creates a new file called report.txt, enter:
cat score.txt names.txt > report.txt

To append (add data to existing) data to a file called foo.txt, enter:
cat >>foo.txt
A champion is someone who gets up, even when he can't
<control-D>

You can send files to sound devices such as /dev/dsp or /dev/audio to make sure sound output and input is working:

cat filename >/dev/dsp
cat recording.au >/dev/audio

You can simply use the following command for recording voice sample and play back with it cat command:

dd bs=8k count=4 </dev/audio >testing123.au
cat testing123.au >/dev/audio

No cat cannot print in reverse order but tac command can concatenate and print files in reverse:

tac fileName
cat fileName | tac
tac <<<"$myFileName"

Referência: Linux / Unix: Cat Command Examples

sexta-feira, 21 de outubro de 2011

Linux: getting flash videos from almost deleted files


#!/bin/sh

DATE=$(date +%Y.%m.%d-%H:%M:%S)

lsof | grep Flash | while read LINE; do
PID=$(echo "${LINE}" | awk '{ print $2 }')
FD=$(echo "${LINE}" | awk '{ print $4 }' | sed s/[a-zA-Z]//)
cat /proc/${PID}/fd/${FD} > ~/"${DATE}"-${FD}.flv
done

exit 0


It used to be easy: if you wanted to save a video played using Flash plugin, it was as easy as copying a file from browser's cache. Why use special webpages or plugins, when you could just:

cp /tmp/Flash* ~/video.flv

In other words: you already had that file downloaded by the flash plugin! But it seems Adobe changed this in one of recent updates, and there is no /tmp/Flash* file anymore... or maybe it is?

The cached movie is still written to the filesystem. It is quickly unlinked (a filesystem term for deleting a file) by the plugin, but the plugin still keeps a handle to the file. The result is that the cache file is no longer visible in the directory, but it occupies space on disk and can be read by that handle. This is how filesystems on Linux operate: as long as there is at least one handle to a file, such file won't be deleted from the filesystem.

Now we need to use two tools. First is lsof, which shows all opened handles by all processes. The key knowledge is that the deleted file is still created as /tmp/Flash*. Lets find the handle:

liori% lsof|grep Flash
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
firefox-b 23220 liori 83u REG 254,0 10565348 929 /tmp/FlashXXQCq4K0 (deleted)
I added lsof's header to make it clearer. Note that funny (deleted) remark—when you check the contents of /tmp, you won't see that file! We're interested in the PID and the FD number. FD is the opened handle's number, and PID is an identifier used to distinguish different programs.

Second tool is the /proc filesystem. This is a special directory existing on all commonly used Linux installations. It contains data about running system: driver settings, process list, diagnostic information. What's most interesting is that it contains files representing all opened file handles. In our case (PID=23220 and FD=83) the handle representing our deleted file is /proc/23220/fd/83. Again, if you just try to list that directory, you will only see a broken symlink. But what if you do this?

liori% cat /proc/23220/fd/83 >video.flv
...you'll get the contents of the deleted file!

This technique is of course not only useful to grab videos downloaded by your flash plugin. Any time you delete a file, but realize that it is still opened by some program, you can recover it.

http://liori.jogger.pl/2010/11/08/getting-flash-videos-from-almost-deleted-files/

sábado, 27 de agosto de 2011

Fedora 15: Intel Corporation Mobile 4 Series Chipset Integrated Graphics Controller

I get a black screen upon boot if inteldrmfb is enabled. So I needed to boot with the option "nomodeset". But with this option I could just use the vesa driver in Xorg.



One solution is:

1) Remove "nomodeset" and "vga" options from kernel boot parameters

2) Add this options to kernel parameters:

i915.modeset=1 video="inteldrmfb:1440x900"

3) Run setpci -s 00:02.0 F4.B=00 as root to turn the backlight back on. You can do this automatically on boot putting this command in /etc/rc.local



Now you can use intel driver in Xorg.



Reference: http://en.gentoo-wiki.com/wiki/Intel_GMA

quinta-feira, 11 de agosto de 2011

Drunk Penguins

Drunk Penguins
Drunk Penguins