Linux Files & Commands
Directory | Description |
---|---|
/ | Root |
/boot | For Linux kernel and boot loader files.The kernel is a file called vmlinuz. |
/etc | Configuration files (All text files). /etc/passwd Here users are defined & essential information for each user is kept like username, password (Encrypetd & stored in shadow), group id, userid, user id info, home directory, command shell etc… . Password is stored in /etc/shadow file not in /etc/passwd /etc/fstab table of devices that get mounted when your system boots. defines your disk drives. /etc/hosts Lists the network host names and IP addresses that are intrinsically known to the system. /etc/init.d This directory contains the scripts that start various system services at boot time. |
/bin /usr/bin |
contains most of the executable programs for the system. /bin : system requires to operate, /usr/bin contains applications for the system’s users. |
/sbin /usr/sbin |
Executables for system administration by the superuser. |
/usr | Things that support user applications /usr/share/X11 Support files for the X Windows system /usr/share/dict Dictionaries for the spelling checker. Ckeck look and ispell ./usr/share/doc documentation files in a variety of formats. /usr/share/man Place for man pages. /usr/src Source code files.(if kernel source code package is installed) |
/usr/local /usr/local/bin |
Used for the installation of software for local machine. |
/var | Files that change as the system is running. /var/log log files updated as the system runs. /var/spool This directory is used to hold files that are queued for some process, such as mail messages and print jobs. Eg: local email is first stored in /var/spool/mail
|
/lib | shared libraries (like .dll in Windows) |
/dev | Devices (as files) that are available to the system. /dev/sda (/dev/hda on older systems) is the first IDE hard drive. |
/proc | processes running on the system. Many of these entries can be viewed. Eg. /proc/cpuinfo . This entry will tell you what the kernel thinks of your CPU. |
/media /mnt |
The /media directory is used for mount points. This process of attaching (devices attached to the file system tree in various places) a device to the tree is called mounting. For a device to be available, it must first be mounted. When your system boots, it reads a list of mounting instructions in the file /etc/fstab, which describes which device is mounted at which mount point in the directory tree. This takes care of the hard drives, but you may also have devices that are considered temporary, such as CD-ROMs and floppy disks. Since these are removable, they do not stay mounted all the time. The /media directory is used by the automatic device mounting mechanisms found in modern desktop oriented Linux distributions. On systems that require manual mounting of removable devices, the /mnt directory provides a convenient place for mounting these temporary devices. You will often see the directories /mnt/floppy and /mnt/cdrom. To see what devices and mount points are used, type mount. |
Commands to see processes
+ top
+ ps -ef
+ GUI : System monitor (GNOME, KDE System -> Monitor)
+ kill -9 to terminate.
Error in file access. (File Permission)
+ Ownership permission (ugo -> USER, GROUP & OTHER)
+ Viewing Permission (r=4; w=2; x=1)
+ eg: 700 (rwx for u, none got g,o)
+ chmod for changing file permission (chmod 771 file.sh)
what is there in exe Folder.
grep : Search a pattern in File.
grep ‘pattern to search’ file1 file2
grep -i -n ‘administrator’ file1.txt
- Ignoring the case ( -i)
- Displaying line Numbers ( -n )
Find a pattern recursively
- grep -r “texthere” .
- Recursively search “texthere” in PWD.
Given directory hierarchy - Find a file
find / -name 'program.c' 2>errors.txt
- Start searching from the root directory (i.e / directory)
-
-name
: Given search text is the filename rather than any other attribute of a file -
'program.c'
Search text that we have entered. Always enclose the filename in single quotes.. why to do this is complex.. so simply do so. -
$ find /mp3collection -name '*.mp3' -size -5000k
find in /mp3collection, only those mp3 files that have a size less than 5000 Kilobytes ( < 5MB) -
$ find / -size +10000k
search from the / directory for any file that is larger than 10000k (> 10MB)
connect to remove server securely.
+ `ssh remote_username@remote_host`
+ SSH keys should be generated on the computer you wish to log in from. This is usually your local computer. Enter the following into the command line. `ssh-keygen -t rsa`
remove a file from remote server
ssh username@domain.com 'rm /some/where/some_file.war'
diff : compare the two files.
+ cmp returns first occurrence of difference
+ diff returns all differences