Unix

From BC$ MobileTV Wiki
Jump to: navigation, search

Unix is the name of a popular open source operating system.


Commands

[1]

System Info

whoami

finger

man

date

cal

uptime

Searching Filesystem

grep

locate

find

[2]

whereis

which

Port Scanning

By default Nmap does a standard TCP SYN scan on the top 1000 ports of host. I never really use this by itself, get verbose output using "-vv" argument:

nmap -vv host

Nmap accepts target specification in loads of different formats including plain IP addresses, CIDR ranges and dash notation

nmap hostname

-or-

nmap 123.123.123.1–255

If you just want to find which hosts are alive, you can perform a ping scan with "-sn" argument:

nmap -sn 123.123.123.1/24

In some casess, a given host may disallow ping, so skipping "ping checks" can be done using "-Pn":

nmap -Pn <HOSTNAME|IP_ADDRESS>

To scan specific port ranges (i.e. outside the default/common 1000 ports scanned), use:

nmap -p 1–65535 <HOSTNAME|IP_ADDRESS>

Discover OS version with "-O" argument, and what service(s) are runnign using "-sV" which takes a "version-intensity" where 0 is a lower accuracy but fast/shallow scan, and 9 is a maximum accuracy but slow/deep scan:

nmap -sV — version-intensity 9 -O <HOSTNAME|IP_ADDRESS>

Find specific security vulnerabilities using the ".nse" scripts that come installed with the nmap tool:

 nmap --script=smb-vuln-cve-2017–7494 <HOSTNAME|IP_ADDRESS> 

Lastly, Firewalls can attempt to be circumvented (or at least probed) using: [3] [4]


Files & Directories

cd

pwd

mkdir

rm

ls

lsof

ln

mv

cp

scp

rsync


Text Output & String Operations

cat

more

head

tail

sed

Stream Editor (SED) is a command/tool which allows you to filter and transform text from the command line.

[5] [6] [7] [8] [9] [10] [11] [12]

cut

[13]

File Permissions

chmod

Change file or folder permissions. EXAMPLE:

chmod 755 SomeFile.csv.zip

755 = Read for Everyone, Write for Owner and Group, Execute for Owner and Group

chown

Change the owner of a file. EXAMPLE:

chown SomeUser SomeFile.csv.zip


Text Editors

vi

[16] [17]

emacs

nano

pico

Tools


Resources


Tutorials


External Links


References

  1. 3 Terminal Commands to Increase Your Productivity: https://medium.com/better-programming/3-terminal-commands-to-increase-your-productivity-9dbab9f1a015
  2. Linux shell, how to use the exec option in find with examples: https://linuxaria.com/howto/linux-shell-how-to-use-the-exec-option-in-find-with-examples
  3. Guide to Nmap — Port Scanning is Just The Beginning: https://medium.com/@hakluke/haklukes-guide-to-nmap-port-scanning-is-just-the-beginning-25d971692fdb
  4. Nmap Network Scanning -- Port Scanning Techniques, Chapter 15 - Nmap Reference Guide: https://nmap.org/book/man-port-scanning-techniques.html
  5. Stream Editor - Quick Guide: https://www.tutorialspoint.com/sed/sed_quick_guide.htm
  6. Sed - An Introduction and Tutorial by Bruce Barnett: http://www.grymoire.com/Unix/Sed.html
  7. Linux SED command help: https://www.computerhope.com/unix/used.htm
  8. Example Uses of Sed in Linux: https://www.lifewire.com/example-uses-of-sed-2201058
  9. Learning Linux Commands -- sed: https://linuxconfig.org/learning-linux-commands-sed
  10. What is the difference between p and P in sed?: https://stackoverflow.com/questions/20194488/what-is-the-difference-between-p-and-p-in-sed
  11. How do you “debug” a regular expression with sed?: https://stackoverflow.com/questions/4052253/how-do-you-debug-a-regular-expression-with-sed
  12. How to extract text from a string using sed?: https://stackoverflow.com/questions/11568859/how-to-extract-text-from-a-string-using-sed
  13. Extract substring in Bash: https://stackoverflow.com/questions/428109/extract-substring-in-bash
  14. vi Editor “Cheat Sheet”: http://www.atmos.albany.edu/daes/atmclasses/atm350/vi_cheat_sheet.pdf
  15. Vi Cheat Sheet / Linux Terminal Cheat Sheet (PDF): http://www.smashingmagazine.com/2010/05/vi-editor-linux-terminal-cheat-sheet-pdf/
  16. How to copy paste contents in VI editor?: https://askubuntu.com/questions/256782/how-to-copy-paste-contents-in-vi-editor
  17. Why every software engineer should use vim: https://levelup.gitconnected.com/why-every-software-engineer-should-use-vim-b9fb97e69d97
  18. Wikipedia: Pico (text editor)
  19. Upgrading and installing packages through the Cygwin command-line?: https://superuser.com/questions/40545/upgrading-and-installing-packages-through-the-cygwin-command-line/301026#301026
  20. https://askubuntu.com/questions/645027/running-a-script-created-in-notepad-windows-on-ubuntu
  21. PDF export of TL;DR pages for Unix/Linux: https://tldr.sh/assets/tldr-book.pdf
  22. dos2unix MAN: http://linuxcommand.org/man_pages/dos2unix1.html

See Also

OS | DOS | SSH | Mac | Linux