Cheatography
                https://cheatography.com
            
        
        
    
                   
                            
    
                    Some basic commands used in Linux for white hat/ethical hacking purposes, as well as just some good general knowledge in linux with networking.
                    
                 
                    
        
        
            
    
        
                            
        
                
        
            
                                
            
                
                                                | General Navigation and Bash Commands
                        
                                                                                    
                                                                                            | pwd | Show current directory |  
                                                                                            | mkdir directory | Make directory directory |  
                                                                                            | rmdir directory | Remove directory |  
                                                                                            | cd directory | Change to directory directory |  
                                                                                            | cd .. | Go up a directory (the parent directory) |  
                                                                                            | cd | Change to home directory |  
                                                                                            | ls | list files (in current directory) |  
                                                                                            | cat file | Display contents of file |  
                                                                                            | ls directory | list files in specified directory |  
                                                                                            | whoami | Show your username |  
                                                                                            | uname -a | Show system and kernel |  
                                                                                            | head -n1 /etc/issue | Show distrobution |  
                                                                                            | man command | Show manual/information for specified command |  
                                                                                            | uptime | Show uptime |  
                                                                                            | date | Show system date |  
                                                                                            | mount | Show mounted file systems |  ls Options
                        
                                                                                    
                                                                                            | -a | Show all plus hidden files |  
                                                                                            | -R | Recursive list |  
                                                                                            | -r | Reverse order |  
                                                                                            | -t | Sort by last modified |  
                                                                                            | -S | Sort by file size |  
                                                                                            | -l | Long listing format |  
                                                                                            | -1 | One file per line |  
                                                                                            | -m | Comma-separated output |  
                                                                                            | -Q | Quoted output |  grep
                        
                                                                                    
                                                                                            | grep option string files | Search for string in files |  
                                                                                            | -i | Case insensitive search |  
                                                                                            | -r | Recursive search |  
                                                                                            | -v | Inverted search |  
                                                                                            | -c | Print count of matching lines |  
                                                                                            | -o | Show matched part of file only |  More Search Commands
                        
                                                                                    
                                                                                            | find /dir/ -name name | Find files starting with name in dir |  
                                                                                            | find /dir/ -user name | Find files owned by name in dir |  
                                                                                            | whereis command | Find binary source manual for command |  
                                                                                            | locate file | Find file with quick search of system index |  
                                                                                            | which file | Shows path to file |  Add 2>/dev/null at the end to discard error messages |  | File Manipulation
                        
                                                                                    
                                                                                            | touch | Create, change, modify timestamps of a file |  
                                                                                            | echo | Print specified text |  
                                                                                            | mv | Move source to directory; Rename Old to New |  
                                                                                            | rm | Remove files or directories |  
                                                                                            | rm -f | Ignore nonexistent files |  
                                                                                            | rm -i | Prompt before every removal |  
                                                                                            | rm -I | Prompt once before removing more than 3 files |  
                                                                                            | rm -r | Remove directories and their contents recursively |  
                                                                                            | cp file1 file2 | Copy file1 to file2 |  
                                                                                            | cp -b | Backup (doesn't support argument) |  
                                                                                            | cp -f | If file cannot be opened remove and try again |  
                                                                                            | cp -l | Hard link files instead of copying |  
                                                                                            | cp -n | Do not overwrite existing file |  
                                                                                            | cp -s | Make symbolic link instead of copying |  
                                                                                            | cp -r | Copy directories recursively |  
                                                                                            | cp -u | Copy only when SOURCE file is newer than destination file or when destination file is missing |  Permissions (chmod)
                        
                                                                                    
                                                                                            | chmod u  file | Change owner permission of file |  
                                                                                            | chmod g file | Change group permission of file |  
                                                                                            | chmod o file | Change all others' permission of file |  
                                                                                            | chmod a file | Change everyone's permission of file |  
                                                                                            | r | permission to read symbol |  
                                                                                            | w | permission to write symbol |  
                                                                                            | x | permission to execute symbol |  
                                                                                            | chmod o+r file | Adds the "read" ability to "other" users |  
                                                                                            | chmod o-r file | Removes the "read" ability from "other" users |  
                                                                                            | chmod 777 file | Adds rwx permissions to all users using octal notations |  I advise looking up an octal notations table/explaination for any help understanding the numbers and their placement, this is just for a quick reference. Ownership (chown)
                        
                                                                                    
                                                                                            | chown newowner file | Change user owner of file to newowner |  
                                                                                            | chown :groupname file.txt | Change group owner of file.txt to groupname |  
                                                                                            | chown newowner:groupname file.txt | Change user owner and group owner of file |  
                                                                                            | -f | Suppress most error messages |  
                                                                                            | -R | Make changes recursively |  
                                                                                            | -H | If cmd argument is symbolic link, traverse it |  
                                                                                            | -L | Traverse every symbolic link to a directory encountered |  
                                                                                            | -h | Affect each symbolic link instead of any referenced file |  Processes
                        
                                                                                    
                                                                                            | ps | Show snapshot of current processes |  
                                                                                            | top | Show realtime processes |  
                                                                                            | kill pid | Kill process with ID pid |  
                                                                                            | pkill name | Kill process with name name |  
                                                                                            | killall name | Kill all process with names beginning with name |  |  | Basic Networking Commands
                        
                                                                                    
                                                                                            | ifconfig | Show details of Network settings (IP, version, etc) |  
                                                                                            | whois | Shows site owner and DNS name server |  
                                                                                            | nslookup | Shows nameservers and IP Addresses |  
                                                                                            | traceroute | Shows routing information to host |  
                                                                                            | nmap | Port scanning (TCP, UDP) |  
                                                                                            | ping/ping6 | Send ICMP pings; Also checks latency |  
                                                                                            | route | Show/manipulate IP routing table |  
                                                                                            | arp | Show/manipulate ARP cache |  
                                                                                            | ip | See ARP cache, neighbor table, add routes |  
                                                                                            | nc | Show various network info |  
                                                                                            | tcpdump | Capture network traffic |  
                                                                                            | dig website | Show various IP information |  Netcat (nc)
                        
                                                                                    
                                                                                            | nc host port | Connect to remote server(s) |  
                                                                                            | nc -l IPaddress port | Listen mode; listen for incoming connections |  
                                                                                            | -p | Specify port number |  
                                                                                            | -v | Verbose mode |  
                                                                                            | -z | Scan for open ports |  
                                                                                            | -q | Specify delay before closing connection |  
                                                                                            | -g | Source-routing hop point(s) up to 8 |  
                                                                                            | -n | Numeric-only IP addresses |  
                                                                                            | -s address | local source address |  
                                                                                            | -c string | specify shell cmds to execute after connect |  
                                                                                            | -e filename | Specify filename to execute after connect (if no working /bin/sh) |  tcpdump
                        
                                                                                    
                                                                                            | -A | Print in ASCII |  
                                                                                            | -c count | Exit after capturing count packets |  
                                                                                            | -D | Show available interfaces |  
                                                                                            | -e | Print link-level header on each line |  
                                                                                            | -F file | Use file as filter expression |  
                                                                                            | -L | List data link types for interface |  
                                                                                            | -n | Don't convert addresses to names |  
                                                                                            | -p | Don't capture in promiscuous mode |  
                                                                                            | -q | Quick Output |  
                                                                                            | -r file | Read packets from file |  
                                                                                            | -s len | Capture up to len bytes per packet |  
                                                                                            | -S | Print absolute TCP seq numbers |  
                                                                                            | -t | Don't print timestamps |  
                                                                                            | -w file | Write captured packets to file |  
                                                                                            | -y type | Specify data-link type |  
                                                                                            | -Z user | Drop privileges from root to user |  | 
            
                            
            
            
        
        
        
        
        
            
    
        
          
Created By
Metadata
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets