# Standard Linux Commands
This page contains some standard linux commands that are available for use across all linux systems but are easy to forget that they exist or using them can get confusing sometimes.
#### `wc` Command
This command is used to count things in linux and supports piping. It can be used for multiple purposes as shown below.
Syntax:
```
wc OPTION... [FILE]...
```
###### Options
- `-l` / `--lines` - Print number of lines.
- `-w` / `--words` - Print number of words.
- `-m` / `--chars` - Print the number of characters.
- `-c` / `--bytes` - Print the number of bytes.
- `-L` / `--max-line-length` - Print the length of the longest line.
Default Output:
```
# wc fileA
20 30 60 fileA
```
Here, _20_ is the number of lines, _30_ is the number of words & _60_ is the number of characters in the file.
Generic uses:
Standard usage (Pipe Back)
```
wc < fileA
```
Multiple Files
```
# wc fileA fileB
```
_Output:_
```
20 40 60 fileA
60 80 100 fileB
80 120 160 total
#
```
Number of words (Piped Output)
```
cat /etc/shadow | wc -w
```
Number of lines (Piped Output)
```
cat /etc/shadow | wc -l
```
###### How to count number of lines in a file using `wc`
```
wc -l /path/to/file
```
###### How to count number of words in a file using `wc`
```
wc -w /path/to/file
```
###### How to count number of lines output by a command using `wc`
```
example_command | wc -l
```
###### How to count number of files in current directory using `wc`
```
find . -type f | wc -l
```
#### `ln` Command - How to create symbolic links / sys links in Linux.
##### General Explaination and use-case
There are two types of system links in linux:
1. Hard Links: Its is like having an alias name to an existing file. It links _(better term: syncs)_ two or more file names with the same [inode](https://en.wikipedia.org/wiki/Inode). **You can only create hardlinks for files & folders on the same filesystem or partition**. One file can have multiple hardlinks.
2. Soft Links: A soft link can be related to a shortcut in windows, it allows a file to be accessed from one directory to other without having to keep 2 copies of it. Soft Links can be created across different filesystems and partitions.
##### How to use ln command
By default `ln` command creates **Hard Links**, To make **Soft Links**, We can use the `-s` _(`--symbolic`)_ flag
Syntax:
```python
ln -s [OPTIONS] SOURCE_FILE DESTINATION_LINK
```
`DESTINATION_LINK` is optional, If that is not specified then it will create a system link in the current working directory with the same name.
::: success
The `ln` command provides no output if ran successfully.
:::
>| # Examples
>| SysLink a Normal file
>| ```
>| ln -s file1 file2
>| ```
>| SysLink a Normal file in different directories
>| ```
>| ln -s /root/file1 /var/www/html/file1
>| ```
>| SysLink a Normal Directory to another
>|
>| ```ln -s /root/downloads /downloads```
###### **How to see if a file is a System Link:**
To see if a file is already a system link/sysLink/symbolic link, We can use the `ls` command with the `-l` flag. Syntax:
```
# ls -l syslinked_file
lrwxrwxrwx 1 root root 9 Nov 22 2004 /root/og_file -> syslinked_file
#
```
###### **How to overwrite a System Link:**
To overwrite an existing sysLink when the `DESTINATION_FILE` already exists as a sysLink, we can use the -f flag. Syntax Below:
```
ln -sf new-file.conf existing-syslink.conf
```
###### **How to remove/delete a System Link:**
To delete/remove a sysLink we can use the `rm` or `unlink` command. Please note that both commands work exactly the same._[Refrence](https://linuxize.com/post/how-to-remove-symbolic-links-in-linux/)_
::: danger
Removing or Moving away the Source file will cause the sysLink to break and it won't work anymore. its is best advised to remove any broken sysLinks.
:::
Syntax:
`unlink` Command
```
unlink symlink_to_remove
```
`rm` Command
```
rm symlink_to_remove
```