Unix
Unix is the name of a popular open source operating system.
Contents
Commands
System Info
whoami
finger
man
date
cal
uptime
Searching Filesystem
grep
- 12 Practical Examples of Linux grep Command: https://www.tecmint.com/12-practical-examples-of-linux-grep-command/
locate
find
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
- lsof command: https://www.tutorialspoint.com/unix_commands/lsof.htm
ln
mv
cp
scp
- scp command Tutorial: https://garron.me/en/articles/scp.html
rsync
- Using rsync to synchronize a local and remote directory: http://bencane.com/2014/01/07/using-rsync-to-synchronize-a-local-and-remote-directory/
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
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
- Linux and Unix chown command: http://www.computerhope.com/unix/uchown.htm
Text Editors
vi
- vi Cheat Sheet: http://www.lagmonster.org/docs/vi.html[14][15]
- Notepad++ Unix to DOS line endings: http://www.larshaendler.com/2013/06/10/notepad-unix-to-dos-line-endings/ (don't forget to convert any Windows-based line endings/formatting before pasting into a Shell terminal within VI, or problems will occur)
emacs
nano
- Nano text editor: https://www.nano-editor.org/
pico
- pico editor: http://www.guckes.net/pico/[18]
Tools
- cygwin: https://cygwin.com | MIRRORS (that Linux/Unix CLI feeling, on Windows)[19][20]
- chmod - calculator: http://www.onlineconversion.com/html_chmod_calculator.htm
- PsTools ("ps" command for windows): http://technet.microsoft.com/en-us/sysinternals/bb896649.aspx
- Find which process is running on a specific port: http://zakaria.se/knwoledge_base/find_which_process_is_running_on_a_specific_port.html
- Top Ten Unix/Linux Distributions: http://distrowatch.com/dwres.php?resource=major
Resources
- TLDR pages: https://tldr.sh | DEMO (simplified & community-driven man pages)[21]
- Unix and Linux System Administration Handbook (BOOK): http://www.goodreads.com/book/show/8772005-unix-and-linux-system-administration-handbook-4-e
- Unix/Linux Command Cheat Sheet: http://fosswire.com/post/2007/08/unixlinux-command-cheat-sheet/
- DOS-2-Unix (for windows): http://sourceforge.net/projects/dos2unix/ (convert Windows newline/special characters to Unix equivalent)
- Dos2Unix / Unix2Dos (for Unix): http://waterlan.home.xs4all.nl/dos2unix.html (Text file format converters)[22]
- Unix Toolbox: http://cb.vu/unixtoolbox.xhtml
- TMUX - A guide to increase your Unix productivity: http://apiumtech.com/blog/tmux-cheat-sheet-tips-tricks/
Tutorials
- Unix tutorial: http://www2.ocean.washington.edu/unix.tutorial.html
- Learn Enough Command Line to Be Dangerous: https://www.learnenough.com/command-line-tutorial
- Bash Guide for Beginners: http://tldp.org/LDP/Bash-Beginners-Guide/html/index.html
- Shell Scripting Primer: http://developer.apple.com/library/mac/#documentation/OpenSource/Conceptual/ShellScripting/Introduction/Introduction.html
- How to run .sh file Shell Script in UNIX: http://www.cyberciti.biz/faq/run-execute-sh-shell-script/ (when "./" won't work)
- How to redirect (Linux/Unix) console output to a file AND stdout: http://stackoverflow.com/a/418899/335867
- Convert camelCase to underscores (camel_case) using sed: http://www.commandlinefu.com/commands/view/2038/convert-camelcase-to-underscores-camel_case
- How to Create, Update and Remove Soft link in UNIXRead more: http://javarevisited.blogspot.com/2011/04/symbolic-link-or-symlink-in-unix-linux.html
- How to Find and Delete Broken Symlinks on Linux: https://www.howtogeek.com/698838/how-to-find-and-delete-broken-symlinks-on-linux/
- Display timestamp in dd/mm/yyyy_hh:mm:ss:ms in Unix or Linux: https://unix.stackexchange.com/questions/45926/display-time-stamp-in-dd-mm-yyyy-hhmmssms-in-unix-or-linux
- How To Use chmod and chown Command: https://www.cyberciti.biz/faq/how-to-use-chmod-and-chown-command/ (remmbers its always of the format chown USER:GROUP)
- Recursive chown starting with the directory above current directory: https://askubuntu.com/questions/631534/recursive-chown-starting-with-the-directory-above-current-directory (use the command "sudo chown -R USER:USER <FILE_OR_DIRECTORY>")
- How to remove a single line from history?: https://unix.stackexchange.com/questions/49214/how-to-remove-a-single-line-from-history
- How can I assign the output of a command to a shell variable?: https://unix.stackexchange.com/questions/16024/how-can-i-assign-the-output-of-a-command-to-a-shell-variable#16027
- Bash -- double equals vs -eq: https://unix.stackexchange.com/questions/16109/bash-double-equals-vs-eq
- How can I make chown work recursively?: https://superuser.com/questions/260925/how-can-i-make-chown-work-recursively
- My Favorite Command-Line Shortcuts: https://henrikwarne.com/2018/08/11/my-favorite-command-line-shortcuts/ (escaped-dot = last typed part of command, CTRL+a = Move to the beginning of the line, CTRL+e = Move to the end of the line, CTRL+u = Clear the text on the line before current position, CTRL+w = Delete the word before cursor position)
- Make cd follow symbolic links: https://unix.stackexchange.com/questions/55713/make-cd-follow-symbolic-links
- What Is the Unix Epoch, and How Does Unix Time Work?: https://www.howtogeek.com/759337/what-is-the-unix-epoch-and-how-does-unix-time-work/
External Links
- wikipedia: Unix
- wikipedia: Hosts (file)
- wikipedia: List of Unix commands
- AT&T Archives -- The UNIX Operating System: https://www.youtube.com/watch?v=tc4ROCJYbm0
- Running a shell script through Cygwin on Windows: https://stackoverflow.com/questions/15736898/running-a-shell-script-through-cygwin-on-windows
- Chapter 2. Starting Off With a Sha-Bang: http://tldp.org/LDP/abs/html/sha-bang.html
- What is the preferred Bash shebang?: https://stackoverflow.com/questions/10376206/what-is-the-preferred-bash-shebang
- Commenting in BASH script: https://stackoverflow.com/questions/1455988/commenting-in-bash-script
- Notepad++ -- Convert EOL from Windows to Unix after document has been created?: https://superuser.com/questions/1158769/notepad-convert-eol-from-windows-to-unix-after-document-has-been-created
- DOS vs. Unix Line Endings: http://www.cs.toronto.edu/~krueger/csc209h/tut/line-endings.html
References
- ↑ 3 Terminal Commands to Increase Your Productivity: https://medium.com/better-programming/3-terminal-commands-to-increase-your-productivity-9dbab9f1a015
- ↑ 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
- ↑ Guide to Nmap — Port Scanning is Just The Beginning: https://medium.com/@hakluke/haklukes-guide-to-nmap-port-scanning-is-just-the-beginning-25d971692fdb
- ↑ Nmap Network Scanning -- Port Scanning Techniques, Chapter 15 - Nmap Reference Guide: https://nmap.org/book/man-port-scanning-techniques.html
- ↑ Stream Editor - Quick Guide: https://www.tutorialspoint.com/sed/sed_quick_guide.htm
- ↑ Sed - An Introduction and Tutorial by Bruce Barnett: http://www.grymoire.com/Unix/Sed.html
- ↑ Linux SED command help: https://www.computerhope.com/unix/used.htm
- ↑ Example Uses of Sed in Linux: https://www.lifewire.com/example-uses-of-sed-2201058
- ↑ Learning Linux Commands -- sed: https://linuxconfig.org/learning-linux-commands-sed
- ↑ 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
- ↑ How do you “debug” a regular expression with sed?: https://stackoverflow.com/questions/4052253/how-do-you-debug-a-regular-expression-with-sed
- ↑ How to extract text from a string using sed?: https://stackoverflow.com/questions/11568859/how-to-extract-text-from-a-string-using-sed
- ↑ Extract substring in Bash: https://stackoverflow.com/questions/428109/extract-substring-in-bash
- ↑ vi Editor “Cheat Sheet”: http://www.atmos.albany.edu/daes/atmclasses/atm350/vi_cheat_sheet.pdf
- ↑ Vi Cheat Sheet / Linux Terminal Cheat Sheet (PDF): http://www.smashingmagazine.com/2010/05/vi-editor-linux-terminal-cheat-sheet-pdf/
- ↑ How to copy paste contents in VI editor?: https://askubuntu.com/questions/256782/how-to-copy-paste-contents-in-vi-editor
- ↑ Why every software engineer should use vim: https://levelup.gitconnected.com/why-every-software-engineer-should-use-vim-b9fb97e69d97
- ↑ Wikipedia: Pico (text editor)
- ↑ 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
- ↑ https://askubuntu.com/questions/645027/running-a-script-created-in-notepad-windows-on-ubuntu
- ↑ PDF export of TL;DR pages for Unix/Linux: https://tldr.sh/assets/tldr-book.pdf
- ↑ dos2unix MAN: http://linuxcommand.org/man_pages/dos2unix1.html