Understanding files and folders

Linux is made with one thought in mind: Everything is a file.

A blank piece of paper is called a file in the world of computers. You can use this piece of paper to write a text or make a drawing. Your text or drawing is called information. A computer file is another way of storing your information.

If you make many drawings then you will eventually want to sort them in different piles or make some other system that allows you to easily locate a given drawing. Computers use folders to sort your files in a hieratic system.

A file is an element of data storage in a file system (file systems manual page). Files are usually stored on harddrives, cdroms and other media, but may also be information stored in RAM or links to devices.

To organize our files into a system we use folders. The lowest possible folder is root / where you will find the user homes called /home/.

/

/home/

/home/mom/

/home/dad/

Behind every configurable option there is a simple human-readable text file you can hand-edit to suit your needs. These days most programs come with nice GUI (graphical user interface) like Mandrakes Control Center and Suses YAST that can smoothly guide you through most configuration. Those who choose can gain full control of their system by manually adjusting the configuration files from foo=yes to foo=no in an editor.

Almost everything you do on a computer involves one or more files stored locally or on a network.

Your filesystems lowest folder root / contains the following folders:

/bin Essential user command binaries (for use by all users)

/boot Static files of the boot loader, only used at system startup

/dev Device files, links to your hardware devices like /dev/sound, /dev/input/js0 (joystick)

/etc Host-specific system configuration

/home User home directories. This is where you save your personal files

/lib Essential shared libraries and kernel modules

/mnt Mount point for a temporarily mounted filesystem like /mnt/cdrom

/opt Add-on application software packages

/usr is the second major section of the filesystem. /usr is shareable, read-only data. That means that /usr should be shareable between various FHS-compliant hosts and must not be written to. Any information that is host-specific or varies with time is stored elsewhere.

/var It contains variable data files. This includes spool directories and files, administrative and logging data, and transient and temporary files.

/proc System information stored in memory mirrored as files.

The only folder a normal user needs to use is /home/you/ - this is where you will be keeping all your documents.

/home/elvis/Documents

/home/elvis/Music

/home/elvis/Music/60s

Files are case sensitive, "myfile" and "MyFile" are two different files.

xargs command

xargs is one of those commands. It takes the standard input and uses it to build a command line.  it's very handy in some situations.
A shell script of its own on my machine, is clean-titles.sh. It simply locates all backup files using the pattern *~, and then passes them on to rm. The result is a nice and clean current working directory and sub-tree.
#!/bin/sh
find -iname '*~' | xargs rm
Do not forget your single quotes around the pattern, otherwise bash might expand it for you.
Another place where xargs comes in handy is when you want to find files based on contents and perform some sort of action on them. For instance, let's locate all those pesky TODO comments and open up those files in kate.
grep TODO -r . | sed 's/:.*//' | sort -u | xargs kate -u
The -u argument to kate ensures that xargs reuses an existing session instead of opening a new window. This is just the way that I prefer to have it, and I even have an alias setup for kate, so that I always used kate -u. However, aliases are not used by xargs, so I have to add the flag explicitly.
Something completely different, but somewhat similar, is the xclip command. In a perfect world, I just might want to give all the TODOs to a colleague. Just replacing xargs with xclip puts all the filenames in the clipboard.
grep TODO -r . | sed 's/:.*//' | sort -u | xclip

Difference between atime ctime and mtime

atime is when the file was last read “ls -la –time=atime”
ctime is the inode change time “ls -la –time=ctime”
mtime is the file modification time. “ls –lu”
Mtime changes when you write to the file. It is the age of the data in the file. Whenever mtime changes, so does ctime. But ctime changes metadata as well. For example, it will change if you change the owner or the permissions on the file or by renaming the file.
Unlike atime and mtime, ctime cannot be set with utime() as used by touch; the only way to set it to an arbitrary value is by changing the system clock.

TCP Hand Shake

To establish a connection, TCP uses a 3-way handshake.
The “three-way handshake” happens thus. The originator sends an initial packet called a “SYN” to establish communication and “synchronize” sequence numbers in counting bytes of data which will be exchanged. The destination then sends a “SYN/ACK” which again “synchronizes” his byte count with the originator and acknowledges the initial packet. The originator then returns an “ACK” which acknowledges the packet the destination just sent him. The connection is now “OPEN” and ongoing communication between the originator and the destination are permitted until one of them issues a “FIN” packet, or a “RST” packet, or the connection times out.
1) Client sends SYN packet to the server
2) Server responds with SYN + ACK packet
3) Client sends back ACK + data that it requested at the first place
http://publib.boulder.ibm.com/infocenter/tpfhelp/current/topic/com.ibm.ztpf-ztpfdf.doc_put.cur/gtps5/ssldig09.gif

How to see on other users keystrokes ?

This will show you every keystrike which user does, and all answers which
he recieves on terminal, INCLUDING PASSWORDS
ps aux | grep pts | grep “\-bash” | grep -v grep
root 30562 0.0 0.1 4836 1356 pts/0 S 19:59 0:00 -bash
root 30648 0.0 0.1 4540 1388 pts/2 R 1:45 0:00 -bash
strace -f -p 30648 2>&1 | egrep “read|recv|write|send|exec|socket|connect”