[pattyo@ponto /dev]$ df
Filesystem
1k-blocks
Used Available Use% Mounted on
/dev/sda7
101089
62455 33415 65% /
/dev/sda1
3636852
1664948 1787160 48% /usr
/dev/sda5
248895
27357 208688 12% /var
/dev/sdb1
991620
380 940868 0% /tmp
/dev/sdb3
900412
49772 804900 6% /home
You can also specify the filesystem
$ df .
Filesystem
1k-blocks
Used Available Use% Mounted on
/dev/sda7
101089
62455 33415 65% /
$ df /var
Filesystem
1k-blocks
Used Available Use% Mounted on
/dev/sda5
248895
27357 208688 12% /var
$ df -h
Filesystem Size
Used Avail Use% Mounted on
/dev/sdb1
3.6G
3.2G 204M 95% /home
$ df -T
Filesystem Type
1k-blocks
Used Available Use% Mounted on
/dev/hda5
ext2
2743460 42744 2561356
2%
/home
To summarize a directory structure or filesystem
To get the contents and size of each subdirectory# du -s /var
30577 /var
# du /var
12 /var/lost+found
15954 /var/lib/rpm
2 /var/lib/games
2 /var/lib/xkb
235 /var/lib/dosemu
1 /var/lib/nfs/sm
....
1 /var/lib/ldap
19834 /var/lib
1 /var/log/uucp
6178 /var/log
1 /var/cache
6 /var/db
1 /var/local
1 /var/lock/subsys
2 /var/lock/console
4 /var/lock/samba
9 /var/lock
...
1 /var/catman/local/catn
27 /var/catman/local
97 /var/catman
1 /var/yp/binding
3 /var/yp
26249 /var
# find . -name core
./Web/images/bars/core
./Src/Misc/core
# find /home -size +10240k -exec ls -l {} \;The file command
# file ./Src/Misc/core
core: ELF 32-bit MSB core file, SPARC, version
1, from 'a.out'
| /dev/hda | First IDE device |
| /dev/hdb | Second IDE device |
| /dev/hdc | Third IDE device (often a CD-ROM drive) |
| /dev/hda1 | First partition on first IDE device |
| /dev/hdb3 | Third partition on second IDE hard disk |
| /dev/sda | First SCSI device |
| /dev/sdb | Second SCSI device |
| /dev/sda4 | Fourth partition on first SCSI hard disk |
| /dev/sdc1 | Frist partition on third SCSI hard disk |
| /dev/hdd5 | Which disk would this be? Which partition? |
# /usr/bin/fdformat
/dev/fd0H1440
# fdisk
* Note the inode, and
block
count, also the superblock info during filesystem build process
# /sbin/dumpe2fs
/dev/fd0
# /sbin/tune2fs -c 5
/dev/fd0
ext3
XFS
-j tells mke2fs to create an
ext3
filesystem with a hidden journal
-J size=<n> size of the
journal,
n is in MB (must be at least 1024 blocks)
mount -t ext3 /dev/xxx /mount_dir* A cleanly unmounted ext3 filesystem can be remounted as ext2 without any other commands.
* Don't forget to update /etc/fstab with new filesystem type!
Filesystem 1k-blocks
Used
Available Use% Mounted on
zelda:/local/mnt/workspace
6244446 703815 5478187 11% /mnt/workspace
*The df command used without any options prints your machines filesystem disk space usage.
Filesystem
1k-blocks
Used Available Use% Mounted on
/dev/sda8
1604932
961000 562404 63% /
* Note that the filesystem on which /mnt/workspace
was
mounted was the root filesystem, /.
| async | Specifies that all reads and writes to the file system should be asynchronous, ie, buffered in memory to improve access speed. |
| auto | Specifies that the file system should be automatically mounted at boot time or when the mount command is used with the -a option. |
| dev | Designates the file system as a special device in the ./dev directory (block or character). |
| exec | Permits execution of binaries stored on file system. |
| noauto | Can only be mounted explicitly, ie, the -a option will not cause the file system to be mounted. |
| noexec | Do not allow execution of any binaries on the mounted file system. Useful for a server's file system containing binaries for architectures other then its own. |
| nouser | Only root can mount the file system. |
| ro | Mount the file system read-only. |
| rw | Mount the file system read-write. |
| suid | Allows special user ID permissions to b used on this file system. |
| user | Allow an ordinary user to mount the file system, ie, floppy or CDROM. |
| owner | Owner is similar to user, with the restriction that the user must be the owner. e.g. for /dev/fd if a login script makes the console user owner of this device. |
| users | Same as user option, except any user can unmount the device. |
| defaults | Use default options: rw, suid, dev, exec, auto, nouser, and async. |
# cp /boot/initrd-x.y.z.img /tmp
# mkdir /tmp/image
uncompress/unzip the image file
# cat /tmp/initrd-x.y.z.img | gunzip > /tmp/initrd.img
mount the uncompressed image file with the loop option
# mount -o loop /tmp/initrd.img /tmp/image
# cd /tmp/image# ls -l
total 6
drwxr-xr-x 2 root root 1024 Oct 31 12:26 bin
drwxr-xr-x 2 root root 1024 Oct 31 12:26 dev
drwxr-xr-x 2 root root 1024 Oct 31 12:26 etc
drwxr-xr-x 2 root root 1024 Oct 31 12:26 lib
-rwxr-xr-x 1 root root 441 Oct 31 12:26 linuxrc
drwxr-xr-x 2 root root 1024 Oct 31 12:26 loopfs
drwxr-xr-x 2 root root 1024 Oct 31 12:26 proc
drwxr-xr-x 2 root root 1024 Oct 31 12:26 sbin
drwxr-xr-x 2 root root 1024 Oct 31 12:26 sysroot
| ext2 | The native Linux file system type. |
| msdos | File system used by DOS and older Windows systems. This is also called the FAT file system. |
| hpfs | THe High Performance file system used by OS/2. |
| iso9660 | File system used on CD-ROMs. |
| nfs | The Network File system, used to allow networked computers to access remote hard disks as part of a local directory structure. |
| smbfs | File system used to mount SMB network devices such as networked Windows computers. This FS is part of the Samba suite. |
| vfat | File system used by Windows 98; also known as FAT32 file system. Provides long filename support. |
| ntfs | File system used by Windows NT. |
| sysv | A standard UNIX System V file system. |
| ext3 | New Journaled filesytem provided with RedHat 7.2 |
| Reiserfs | Journaled filesystem |
| ufs | A UNIX file system type used by Solaris. |
| xfs | High performance journaled file system. |
$ kcontrol

# fdisk /dev/sdb
...create partitions here
...type 82 is linux swap
List partition table:
$ sudo sfdisk -l /dev/sda
Disk /dev/sda: 522 cylinders, 255 heads, 63
sectors/track
Units = cylinders of 8225280 bytes, blocks of
1024 bytes, counting from 0
Device Boot Start
End
#cyls #blocks Id System
/dev/sda1 *
0+
459 460- 3694918+ 83 Linux
/dev/sda2
460
521 62
498015
5 Extended
/dev/sda3
0
-
0 0
0
Empty
/dev/sda4
0
-
0 0
0
Empty
/dev/sda5
460+ 480
21-
168651 82 Linux swap
/dev/sda6
481+
521 41- 329301
83
Linux
# /sbin/mkswap -c /dev/sdb2
device mnt point
type options backup
fsck
order
------------------------------------------------------------
/dev/sdb2
swap
swap pri=1,defaults
0
0
/dev/sda2
swap
swap pri=1,defaults
0
0
# dd if=/dev/zero
of=/tmp/newswap
bs=1048576 count=2
or
# dd if=/dev/zero
of=/tmp/newswap
bs=1024 count=2048
Note: There are
different
ways to accomplish the same thing
bs: block size;
1024*1024
= 1048576 = 1 MB in first example
count: count this many
input
blocks; in the first example you will have 2 * 1 MB for a file size
# chmod 600 /tmp/newswap
# mkswap /tmp/newswap
Setting up swapspace version 1, size = 2093056 bytes
Enable the swap space
# swapon /tmp/newswap
check to see if it worked
$ cat /proc/swaps
Filename Type Size Used Priority
/dev/sdb5 partition 168640 35832 1
/dev/sda5 partition 168640 35648 1
/tmp/newswap file 2040 0 -3
^^^^^^^^^^^^
$ swapon -s
Disable the swap file
# swapoff /tmp/newswap
$ swapon -s
Filename Type Size Used Priority
/dev/sdb5 partition 168640 35832 1
/dev/sda5 partition 168640 35648 1
To have this swap file active after a reboot you would add it to your /etc/fstab file
/path-to-swap/swapfile swap swap defaults 0 0
$ swapon -s
Filename Type Size Used Priority
/dev/sdb5 partition 168640 42524 1
/dev/sda5 partition 168640 0 1$ free
total used free shared buffers cached
Mem: 158928 151392 7536 744 4852 80432
-/+ buffers/cache: 66108 92820
Swap: 337280 42524 294756$ cat /proc/swaps
Filename Type Size Used Priority
/dev/sdb5 partition 168640 42524 1
/dev/sda5 partition 168640 0 1$ cat /proc/meminfo | head -3
total: used: free: shared: buffers: cached:
Mem: 162742272 155033600 7708672 761856 4972544 109076480
Swap: 345374720 43544576 301830144
$ vmstat 5 5
procs
memory
swap
io
system
cpu
r b w
swpd
free buff cache si so
bi
bo in cs us sy id
1 0 0
42524
6904 4876 80448 0
0
10 2 34 10
49 4 47
0 0 0
42524
6904 4876 80448 0
0
0 0 159 387
11
2 87
0 0 0
42524
6904 4876 80448 0
0
0 0 145 267
5
2 93
0 0 0
42524
6904 4876 80448 0
0
0 0 125 108
1
1 99
0 0 0
42524
6904 4876 80448 0
0
0 0 126 104
1
1 98
FIELD DESCRIPTIONS
Procs
r: The
number of processes waiting for run time.
b: The number
of processes in uninterruptable sleep.
w: The number
of processes swapped out but otherwise runnable. This
field is calculated, but Linux never desperation swaps.
Memory
swpd:
the amount of virtual memory used (kB).
free: the
amount
of idle memory (kB).
buff: the
amount
of memory used as buffers (kB).
cache: amount of memory cached for
frequently used file structures, etc
Swap
si:
Amount
of memory swapped in from disk (kB/s).
so: Amount of
memory swapped to disk (kB/s).
IO
bi:
Blocks
sent to a block device (blocks/s).
bo: Blocks
received
from a block device (blocks/s).
System
in:
The
number of interrupts per second, including the clock.
cs: The number
of context switches per second.
CPU
These
are percentages of total CPU time.
us: user time
sy: system time
id: idle time
Quotas for group users:
/dev/hda6: blocks in use: 55, limits (soft = 512000, hard = 0)
inodes in use: 200, limits (soft = 0, hard = 0)
# edquota -p joe `awk -F: '$3 > 499 {print $1}' /etc/passwd`
# ls -l /usr/bin/sudo
# chmod 4111 /usr/bin/sudo
Files
- has an octal value of 1000
- a long time ago it was used to keep programs resident in memory, back when memory was small and expensive
- today it is ignored on executables
$ ls -ld /tmp
drwxrwxrwt 9 root
root 4096 Apr 14 14:17 /tmp
^^^
# chown someuser /home/someuserchgrp
# chown pattyo.sysadmin testdir
# chown -R someuer
/home/someuser
# chgrp -R staff someuser