---
# System prepended metadata

title: Recitation 6

---

# Recitation6

## Topics Today
- Inode
- Hard link
- Soft link
- Process

# Inode

## What's Inode

- An "index node" (inode) is a data structure in Unix-like file systems.
- It stores metadata about files and directories.

## Attributes

- File type (regular file, directory, symlink, etc.)
- Permissions (read, write, execute)
- Ownership (user and group)
- Size
- Timestamps (modification, access, change)
- Disk block pointers
- Link count

## How to check Inode
```bash=
ls -l myfile.txt
```

or 

```bash=
stat myfile.txt
```
# Hard Link
Hard link points to some space on disk.

directories have 2 or more hard links
   - 1 from its parent directory
   - 1 from itself (.)
   - 1 from each of its subdirectories (via ..)
```bash=
mkdir mydir
stat mydir
```

or
```bash=
ls -i mydir
```

`ln` create a new hard link for an existing file
```bash=
ln myfile.txt testfile.txt
```

`rm` unlinks a file 
```bash=
rm myfile.txt
```

`mv` unlinks a the source file name and relinks it at the destination
```bash=
mv testfile.txt myfile.txt
```

# Soft Link

Symbolic link (soft link) serves as a pointer or reference to another file or directory. It's a way to create shortcuts to files or directories, allowing you to reference them using a different name or location

## 

Creates a symbolic link using the `ln` command with the `-s` option
```bash=
ln -s myfile.txt testlink
```
Then use `stat` to check it.
```
stat testlink
```


# Process

Use `top` or `htop` to check running process


