⁍ 𝐋𝐢𝐧𝐮𝐱 𝐂𝐨𝐦𝐦𝐚𝐧𝐝𝐬 𝐂𝐡𝐞𝐚𝐭𝐬𝐡𝐞𝐞𝐭

Command Usage
ssh ssh (SSH client) is a program for logging into a remote machine and for executing commands on a remote machine.
ls List information about the FILEs (the current directory by default).
cd Change Directory
cat Concatenate files and print on the standard output
file determine file type
du estimate file space usage
find search for files in a directory hierarchy
grep print lines that match patterns
sort sort lines of text files
uniq report or omit repeated lines
strings print the sequences of printable characters in files
base64 base64 encode/decode data and print to standard output
tr Translate, squeeze, and/or delete characters from standard input, writing to standard output.
tar an archiving utility
gzip compress or expand files
bzip2 a block-sorting file compressor
xxd make a hexdump or do the reverse.
mkdir make directories
cp copy files and directories
mv move files and directories
telnet The telnet command is used for interactive communication with another host using the TELNET protocol
nc netcat is a simple unix utility which reads and writes data across network connections, using TCP or UDP protocol.
openssl OpenSSL command line tool
s_client The s_client command implements a generic SSL/TLS client which connects to a remote host using SSL/TLS. It is a very useful diagnostic tool for SSL servers.
nmap Network exploration tool and security / port scanner
diff compare files line by line
bash Bash is an sh-compatible command language interpreter
screen Screen is a full-screen window manager that multiplexes a physical terminal between several processes
tmux tmux is a terminal multiplexer: it enables a number of terminals to be created, accessed, and controlled from a single screen.
bg background a process
fg foreground a process
jobs list processes running in background
& run a command in background
cron daemon to execute scheduled commands
crontab maintain crontab files for individual users
crontab(5) tables for driving cron
more file perusal filter for crt viewing
less opposite of more
vi vim - Vi IMproved, a programmer's text editor
id print real and effective user and group IDs
pwd print working directory
git the stupid content tracker
locate find files by name, quickly
man an interface to the system reference manuals
which locate a command
type lets you query the type of each command.
ps report a snapshot of the current processes.
kill send a signal to a process
uname print system information
chmod change file mode bits
chown change file owner and group
chgrp change group ownership
tail output the last part of files
ln make link between files


Note: These are my notes for personal reference!

𝐁𝐚𝐬𝐢𝐜

┌──(shreyas㉿kali)-[~]
└─$ date
Tuesday 04 January 2022 03:39:43 PM IST

┌──(shreyas㉿kali)-[~]
└─$ cal  
    January 2022      
Su Mo Tu We Th Fr Sa  
                   1  
 2  3  4  5  6  7  8  
 9 10 11 12 13 14 15  
16 17 18 19 20 21 22  
23 24 25 26 27 28 29  
30 31                 

┌──(shreyas㉿kali)-[~]
└─$ df  
Filesystem     1K-blocks     Used Available Use% Mounted on
udev             1953436        0   1953436   0% /dev
tmpfs             399160     1168    397992   1% /run
/dev/sda1      130538556 11247868 112613492  10% /
tmpfs            1995784        0   1995784   0% /dev/shm
tmpfs               5120        0      5120   0% /run/lock
tmpfs             399156       68    399088   1% /run/user/1000
              

┌──(shreyas㉿kali)-[~]
└─$ free                      
               total        used        free      shared  buff/cache   available
Mem:         3991568      672232     2753624        8864      565712     3079888
Swap:         998396           0      998396
            

𝐍𝐚𝐯𝐢𝐠𝐚𝐭𝐢𝐨𝐧

┌──(shreyas㉿kali)-[~]
└─$ pwd                
/home/shreyas
                

┌──(shreyas㉿kali)-[~]
└─$ cd practise           
                                                                                       
┌──(shreyas㉿kali)-[~/practise]
└─$ pwd
/home/shreyas/practise
                                                                                       
┌──(shreyas㉿kali)-[~/practise]
└─$ ls 
hackthebox

Shortcut Result
cd Changes the working directory to your home directory.
cd - Changes the working directory to the previous working directory.
cd ~user_name Changes the working directory to the home directory of user_name. For example, typing cd ~bob will change the directory to the home directory of user “bob.”

┌──(shreyas㉿kali)-[~]
└─$ ls
BugBounty  Documents  Music     practise  Templates
Desktop    Downloads  Pictures  Public    Videos
                                                                                       
┌──(shreyas㉿kali)-[~]
└─$ ls /usr      
bin  games  include  lib  lib32  lib64  libexec  libx32  local  sbin  share  src
                                                                                       
┌──(shreyas㉿kali)-[~]
└─$ ls practise /usr
practise:
hackthebox

/usr:
bin  games  include  lib  lib32  lib64  libexec  libx32  local  sbin  share  src
                                                                                       
┌──(shreyas㉿kali)-[~]
└─$ ls -l          
total 176
drwxr-xr-x  3 shreyas shreyas  4096 Jan  1 17:38 BugBounty
drwxr-xr-x  2 shreyas shreyas  4096 Dec 14 19:34 Desktop
drwxr-xr-x  2 shreyas shreyas  4096 Dec 14 19:34 Documents
drwxr-xr-x  3 shreyas shreyas  4096 Dec 29 15:32 Downloads
drwxr-xr-x  2 shreyas shreyas  4096 Dec 14 19:34 Music
drwxr-xr-x  2 shreyas shreyas  4096 Dec 14 19:34 Pictures
drwxr-xr-x  3 shreyas shreyas  4096 Dec 26 21:40 practise
drwxr-xr-x  2 shreyas shreyas  4096 Dec 14 19:34 Public
drwxr-xr-x  2 shreyas shreyas  4096 Dec 14 19:34 Templates
drwxr-xr-x  2 shreyas shreyas  4096 Dec 14 19:34 Videos

                                                                                       
┌──(shreyas㉿kali)-[~]
└─$ ls -lt
total 40
drwxr-xr-x 3 shreyas shreyas 4096 Jan  1 17:38 BugBounty
drwxr-xr-x 3 shreyas shreyas 4096 Dec 29 15:32 Downloads
drwxr-xr-x 3 shreyas shreyas 4096 Dec 26 21:40 practise
drwxr-xr-x 2 shreyas shreyas 4096 Dec 14 19:34 Desktop
drwxr-xr-x 2 shreyas shreyas 4096 Dec 14 19:34 Documents
drwxr-xr-x 2 shreyas shreyas 4096 Dec 14 19:34 Music
drwxr-xr-x 2 shreyas shreyas 4096 Dec 14 19:34 Pictures
drwxr-xr-x 2 shreyas shreyas 4096 Dec 14 19:34 Public
drwxr-xr-x 2 shreyas shreyas 4096 Dec 14 19:34 Templates
drwxr-xr-x 2 shreyas shreyas 4096 Dec 14 19:34 Videos

                                                                                       
┌──(shreyas㉿kali)-[~]
└─$ ls -lt --reverse                                                               2 ⨯
total 40
drwxr-xr-x 2 shreyas shreyas 4096 Dec 14 19:34 Videos
drwxr-xr-x 2 shreyas shreyas 4096 Dec 14 19:34 Templates
drwxr-xr-x 2 shreyas shreyas 4096 Dec 14 19:34 Public
drwxr-xr-x 2 shreyas shreyas 4096 Dec 14 19:34 Pictures
drwxr-xr-x 2 shreyas shreyas 4096 Dec 14 19:34 Music
drwxr-xr-x 2 shreyas shreyas 4096 Dec 14 19:34 Documents
drwxr-xr-x 2 shreyas shreyas 4096 Dec 14 19:34 Desktop
drwxr-xr-x 3 shreyas shreyas 4096 Dec 26 21:40 practise
drwxr-xr-x 3 shreyas shreyas 4096 Dec 29 15:32 Downloads
drwxr-xr-x 3 shreyas shreyas 4096 Jan  1 17:38 BugBounty
                                                                                       

┌──(shreyas㉿kali)-[~/practise/hackthebox]
└─$ file flag.txt             
flag.txt: ASCII text, with no line terminators
                                                                                       
┌──(shreyas㉿kali)-[~/practise/hackthebox]
└─$ file pack.ovpn 
pack.ovpn: ASCII text

┌──(shreyas㉿kali)-[~/practise/hackthebox]
└─$ cat example | less
                                                                                       
┌──(shreyas㉿kali)-[~/practise/hackthebox]
└─$ less example
Command Action
PAGE UP or b Scroll back one page
PAGE DOWN or space Scroll forward one page
Up arrow Scroll up one line
Down arrow Scroll down one line
G Move to the end of the text file
1G or g Move to the beginning of the text file
/characters Search forward to the next occurrence of characters
n Search for the next occurrence of the previous search
h Display help screen
q Quit less

𝐌𝐚𝐧𝐢𝐩𝐮𝐥𝐚𝐭𝐢𝐧𝐠 𝐟𝐢𝐥𝐞𝐬 𝐚𝐧𝐝 𝐝𝐢𝐫𝐞𝐜𝐭𝐨𝐫𝐢𝐞𝐬

Wildcards Meaning
* Matches any character
? Matches any single character
[characters] Matches any character that is a member of the set characters
[!characters] Matches any character that is not a member of the set characters
[:class:]] Matches any character that is member of the specified class
Character class Meaning
[:alnum:] Matches any alphanumeric character
[:alpha:] Matches any alphabetic characters
[:digit:] Matches any numerical
[:lower:] Matches any lowercase letter
[:upper:] Matches any uppercase
Pattern Matches
* All files
g* Any file beginning with g
b*.txt Any file beginning with b followed by any characters and ending with .txt
Data??? Any file beginning with Data followed by exactly three characters
[abc]* Any file beginning with either an a, a b, or a c
BACKUP.[0-9][0-9][0-9] Any file beginning with BACKUP. followed by exactly three numerals
[[:upper:]]* Any file beginning with an uppercase letter
[![:digit:]]* Any file not beginning with a numeral
*[[:lower:]123] Any file ending with a lowercase letter or the numerals 1, 2, or 3

┌──(shreyas㉿kali)-[~/practise]
└─$ mkdir commandline
                                                                                       
┌──(shreyas㉿kali)-[~/practise]
└─$ ls          
commandline  hackthebox

┌──(shreyas㉿kali)-[~/practise/commandline]
└─$ mkdir dir1 dir2 dir3
                                                                                       
┌──(shreyas㉿kali)-[~/practise/commandline]
└─$ ls
dir1  dir2  dir3

Option Meaning
-a,--archive Copy the files and directories and all of their attributes, including ownerships and permissions.
-i, --interactive Before overwriting an existing file, prompt the user for confirmation.
-r, --recursive Recursively copy directories and their contents. This option (or the -a option) is required when copying directories.
-u, --update When copying files from one directory to another, only copy files that either don’t exist or are newer than the existing corresponding files in the destination directory. This is useful when copying large numbers of files as it skips files that don’t need to be copied
-v, --verbose Display informative messages as the copy is performed.

Option Meaning
-i, --interactive Before deleting an existing file, prompt the user for confirmation.
-r, --recursive Recursively delete directories. This means that if a directory being deleted has subdirectories, delete them too. To delete a directory, this option must be specified.
-f, --force Ignore nonexistent files and do not prompt. This overrides the --interactive option.
-v, --verbose Display informative messages as the deletion is performed.


𝐖𝐨𝐫𝐤𝐢𝐧𝐠 𝐰𝐢𝐭𝐡 𝐜𝐨𝐦𝐦𝐚𝐧𝐝𝐬

┌──(shreyas㉿kali)-[~/practise/commandline]
└─$ type ls      
ls is an alias for ls --color=auto
                                                                                       
┌──(shreyas㉿kali)-[~/practise/commandline]
└─$ type ssh
ssh is /usr/bin/ssh
                                                                                       
┌──(shreyas㉿kali)-[~/practise/commandline]
└─$ type cd 
cd is a shell builtin
                          

┌──(shreyas㉿kali)-[~/practise/commandline]
└─$ which ls           
ls: aliased to ls --color=auto
                                                                                       
┌──(shreyas㉿kali)-[~/practise/commandline]
└─$ which pwd
pwd: shell built-in command
                                                                                       
┌──(shreyas㉿kali)-[~/practise/commandline]
└─$ which cd 
cd: shell built-in command
                                                                                       
┌──(shreyas㉿kali)-[~/practise/commandline]
└─$ which gedit
/usr/bin/gedit
                                                                                       
┌──(shreyas㉿kali)-[~/practise/commandline]
└─$ which firefox
/usr/bin/firefox
                       

┌──(shreyas㉿kali)-[~/practise/commandline]
└─$ man ls         
LS(1)                               User Commands                              LS(1)

NAME
       ls - list directory contents

SYNOPSIS
       ls [OPTION]... [FILE]...

DESCRIPTION
       List  information  about  the FILEs (the current directory by default).  Sort
       entries alphabetically if none of -cftuvSUX nor --sort is specified.

       Mandatory arguments to long options are mandatory for short options too.

       -a, --all
              do not ignore entries starting with .

       -A, --almost-all
              do not list implied . and ..

       --author
              with -l, print the author of each file

 Manual page ls(1) line 1 (press h for help or q to quit)

┌──(shreyas㉿kali)-[~/practise/commandline]
└─$ apropos copy            
cifsdd (8)           - convert and copy a file over SMB
COPY (7)             - copy data between a file and a table
cp (1)               - copy files and directories
cpgr (8)             - copy with locking the given file to the password or group file
cpio (1)             - copy files to and from archives
cppw (8)             - copy with locking the given file to the password or group file
dd (1)               - convert and copy a file
debconf-copydb (1)   - copy a debconf database
git-checkout-index (1) - Copy files from the index to the working tree
gvfs-copy (1)        - Deprecated equivalent of gio copy
install (1)          - copy files and set attributes
mariadb-hotcopy (1)  - a database backup program
mysqlhotcopy (1)     - a database backup program
ntfscp (8)           - copy file to an NTFS volume.
objcopy (1)          - copy and translate object files
ptrepack (1)         - Copy any PyTables Leaf, Group or complete subtree into anothe...
rcp (1)              - OpenSSH secure file copy
rsync (1)            - a fast, versatile, remote (and local) file-copying tool
scp (1)              - OpenSSH secure file copy
ssh-copy-id (1)      - use locally available keys to authorise logins on a remote ma...
svnversion (1)       - Produce a compact version identifier for a working copy.
vfs_shadow_copy (8)  - Expose snapshots to Windows clients as shadow copies.
vfs_shadow_copy2 (8) - Expose snapshots to Windows clients as shadow copies.
x86_64-linux-gnu-objcopy (1) - copy and translate object files
                                                                                       

┌──(shreyas㉿kali)-[~/practise/commandline]
└─$ whatis rm    
rm (1)               - remove files or directories
                                                                                       
┌──(shreyas㉿kali)-[~/practise/commandline]
└─$ whatis ls
ls (1)               - list directory contents
                                                                                       
┌──(shreyas㉿kali)-[~/practise/commandline]
└─$ whatis sudo
sudo (8)             - execute a command as another user
                            

                                                                                       
┌──(shreyas㉿kali)-[~/practise/commandline]
└─$ info ls
Next: dir invocation,  Up: Directory listing

10.1 ‘ls’: List directory contents
==================================

The ‘ls’ program lists information about files (of any type, including
directories).  Options and file arguments can be intermixed arbitrarily,
as usual.

   For non-option command-line arguments that are directories, by
default ‘ls’ lists the contents of directories, not recursively, and
omitting files with names beginning with ‘.’.  For other non-option
arguments, by default ‘ls’ lists just the file name.  If no non-option
argument is specified, ‘ls’ operates on the current directory, acting as
if it had been invoked with a single argument of ‘.’.

   By default, the output is sorted alphabetically, according to the
locale settings in effect.(1)  If standard output is a terminal, the
output is in columns (sorted vertically) and control characters are
output as question marks; otherwise, the output is listed one per line
and control characters are output as-is.

-----Info: (coreutils)ls invocation, 56 lines --Top------------------------------------
Follow xref: gument is specified, ‘ls’ operates on the current directory, acting asif 

[me@linuxbox ~]$ cd /usr; ls; cd -
bin  games  include  lib  local  sbin  share  src
/home/me
[me@linuxbox ~]$
[me@linuxbox ~]$ type foo
bash: type: foo: not found
[me@linuxbox ~]$ alias foo='cd /usr; ls; cd -'
[me@linuxbox ~]$ foo
bin  games  include  lib  local  sbin  share  src
/home/me
[me@linuxbox ~]$
[me@linuxbox ~]$ type foo
foo is aliased to `cd /usr; ls; cd -'
[me@linuxbox ~]$ unalias foo
[me@linuxbox ~]$ type foo
bash: type: foo: not found

𝐑𝐞𝐝𝐢𝐫𝐞𝐜𝐭𝐢𝐨𝐧

┌──(shreyas㉿kali)-[~/practise/commandline]
└─$ ls -l /usr/bin > ls-output.txt
                                                                                       
┌──(shreyas㉿kali)-[~/practise/commandline]
└─$ ls -l                         
total 180
drwxr-xr-x 2 shreyas shreyas   4096 Jan  4 17:21 dir1
drwxr-xr-x 2 shreyas shreyas   4096 Jan  4 17:21 dir2
drwxr-xr-x 2 shreyas shreyas   4096 Jan  4 17:21 dir3
-rw-r--r-- 1 shreyas shreyas 171639 Jan  4 18:21 ls-output.txt
                                                                   

[me@linuxbox ~]$ ls -l /usr/bin >> ls-output.txt

[me@linuxbox ~]$ ls -l /bin/usr 2> ls-error.txt


┌──(shreyas㉿kali)-[~/practise/commandline]
└─$ wc ls-output.txt 
  2557  24294 171639 ls-output.txt
[me@linuxbox ~]$ head -n 5 ls-output.txt
total 343496
-rwxr-xr-x 1 root root       31316 2017-12-05 08:58 [
-rwxr-xr-x 1 root root        8240 2017-12-09 13:39 411toppm
-rwxr-xr-x 1 root root      111276 2017-11-26 14:27 a2p
-rwxr-xr-x 1 root root       25368 2016-10-06 20:16 a52dec
[me@linuxbox ~]$ tail -n 5 ls-output.txt
-rwxr-xr-x 1 root root        5234 2017-06-27 10:56 znew
-rwxr-xr-x 1 root root         691 2015-09-10 04:21 zonetab2pot.py
-rw-r--r-- 1 root root         930 2017-11-01 12:23 zonetab2pot.pyc
-rw-r--r-- 1 root root         930 2017-11-01 12:23 zonetab2pot.pyo
lrwxrwxrwx 1 root root           6 2016-01-31 05:22 zsoelim -> soelim

𝐒𝐞𝐞𝐢𝐧𝐠 𝐭𝐡𝐞 𝐰𝐨𝐫𝐥𝐝 𝐚𝐬 𝐭𝐡𝐞 𝐬𝐡𝐞𝐥𝐥 𝐬𝐞𝐞𝐬 𝐢𝐭

┌──(shreyas㉿kali)-[~]
└─$ echo hello there my name is shreyas                       
hello there my name is shreyas
                                                                                       
┌──(shreyas㉿kali)-[~]
└─$ echo *                             
BugBounty Desktop Documents Downloads Music Pictures practise Public Templates Videos
                                                                                       
┌──(shreyas㉿kali)-[~]
└─$ echo D*
Desktop Documents Downloads
                                                                                       
┌──(shreyas㉿kali)-[~]
└─$ echo *s
Documents Downloads Pictures Templates Videos
                                                                                       
┌──(shreyas㉿kali)-[~]
└─$ echo [[:upper:]]*
BugBounty Desktop Documents Downloads Music Pictures Public Templates Videos
                                                                                       
┌──(shreyas㉿kali)-[~]
└─$ echo /usr/*/share
/usr/local/share
                                                                                      
┌──(shreyas㉿kali)-[~]
└─$ echo ~           
/home/shreyas

                                                                                       
┌──(shreyas㉿kali)-[~]
└─$ echo $((2 + 2))
4

┌──(shreyas㉿kali)-[~]
└─$ echo $(($((5**2)) * 3))
75
      
Operator Description
+ Addition
- Subtraction
* Multiplication
/ Division (but remember, since expansion supports only integer arithmetic, results are integers)
% Modulo, which simply means “remainder”
** Exponentiation
┌──(shreyas㉿kali)-[~]
└─$ echo Front-{A,B,C}-Back
Front-A-Back Front-B-Back Front-C-Back
                                                                                       
┌──(shreyas㉿kali)-[~]
└─$  echo Number_{1..5}
Number_1 Number_2 Number_3 Number_4 Number_5
                                                                                       
┌──(shreyas㉿kali)-[~]
└─$ echo {01..15}
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15
                                                                                       
┌──(shreyas㉿kali)-[~]
└─$ echo a{A{1,2},B{3,4}}b
aA1b aA2b aB3b aB4b
                                                   

Escape Sequence Meaning
\a Bell (an alert that causes the computer to beep)
\b Backspace
\n Newline; on Unix-like systems, this produces a line feed
\r Carriage return
\t tab
┌──(shreyas㉿kali)-[~]
└─$ sleep 10; echo -e "Time's up\a"
Time's up
           

𝐀𝐝𝐯𝐚𝐧𝐜𝐞𝐝 𝐊𝐞𝐲𝐛𝐨𝐚𝐫𝐝 𝐓𝐫𝐢𝐜𝐤𝐬

Key Action
CTRL-A Move the cursor to the beginning of line
CTRL-E Move cursor to the end of the line
CTRL-F Move cursor forward one character; same as the right arrow key
CTRL-B Move cursor backward one character; same as the left arrow key
ALT-F Move cursor one word forward
ALT-B Move cursor backward one word
CTRL-L Clear screen and move the cursor to the top left corner. Same as clear command

Key Action
CTRL-D Delete the character at the cursor location
CTRL-T Transpose the character at the cursor location
ALT-T Transpose the word at the cursor location with the one preceding it.
ALT-L Convert the characters from the cursor location to the end of the word to lowercase.
ALT-U Convert the characters from the cursor location to the end of the word to uppercase.

Sequence Action
!! Repeat the last command. It is probably easier to press the up arrow and ENTER
!number Repeat history list item number.
!string Repeat last history list item starting with string
!?string Repeat last history list item containing string

𝐏𝐞𝐫𝐦𝐢𝐬𝐬𝐢𝐨𝐧𝐬

File Attributes Meaning
-rwx------ A regular file that is readable, writable, and executable by the file’s owner. No one else has any access.
-rw------- A regular file that is readable and writable by the file’s owner. No one else has any access.
-rw-r--r-- A regular file that is readable and writable by the file’s owner. Members of the file’s owner group may read the file. The file is world-readable.
-rwxr-xr-x A regular file that is readable, writable, and executable by the file’s owner. The file may be read and executed by everybody else.
-rw-rw---- A regular file that is readable and writable by the file’s owner and members of the file’s group owner only.
lrwxrwxrwx A symbolic link. All symbolic links have “dummy” permissions. The real permissions are kept with the actual file pointed to by the symbolic link.
drwxrwx--- A directory. The owner and the members of the owner group may enter the directory and create, rename, and remove files within the directory.
drwxr-x--- A directory. The owner may enter the directory and create, rename, and delete files within the directory. Members of the owner group may enter the directory but cannot create, delete, or rename files.

Symbol Meaning
u Short for "user" but means the file or directory owner.
g Group owner
o Short for "others" but means world
a Short for "all". This is a combination of u, g, and o.
Notation Meaning
u+x Add execute permission for the owner.
u-x Remove execute permission from the owner.
+x Add execute permission for the owner, group, and world. This is equivalent to a+x.
o-rw Remove the read and write permissions from anyone besides the owner and group owner.
go=rw Set the group owner and anyone besides the owner to have read and write permissions. If either the group owner or the world previously had execute permission, it is removed.
u+x,go=rx Add execute permission for the owner and set the permissions for the group and others to read and execute. Multiple specifications may be separated by commas.

𝐏𝐫𝐨𝐜𝐞𝐬𝐬𝐞𝐬


𝐍𝐞𝐭𝐰𝐨𝐫𝐤𝐢𝐧𝐠

┌──(shreyas㉿kali)-[~]
└─$ ping youtube.com   
PING youtube.com (142.250.204.46) 56(84) bytes of data.
64 bytes from hkg07s38-in-f14.1e100.net (142.250.204.46): icmp_seq=1 ttl=128 time=149 ms
64 bytes from hkg07s38-in-f14.1e100.net (142.250.204.46): icmp_seq=2 ttl=128 time=151 ms
64 bytes from hkg07s38-in-f14.1e100.net (142.250.204.46): icmp_seq=3 ttl=128 time=188 ms
64 bytes from hkg07s38-in-f14.1e100.net (142.250.204.46): icmp_seq=4 ttl=128 time=140 ms
64 bytes from hkg07s38-in-f14.1e100.net (142.250.204.46): icmp_seq=5 ttl=128 time=139 ms
64 bytes from hkg07s38-in-f14.1e100.net (142.250.204.46): icmp_seq=6 ttl=128 time=120 ms
64 bytes from hkg07s38-in-f14.1e100.net (142.250.204.46): icmp_seq=7 ttl=128 time=131 ms
64 bytes from hkg07s38-in-f14.1e100.net (142.250.204.46): icmp_seq=8 ttl=128 time=148 ms
64 bytes from hkg07s38-in-f14.1e100.net (142.250.204.46): icmp_seq=9 ttl=128 time=137 ms
64 bytes from hkg07s38-in-f14.1e100.net (142.250.204.46): icmp_seq=10 ttl=128 time=132 ms
64 bytes from hkg07s38-in-f14.1e100.net (142.250.204.46): icmp_seq=11 ttl=128 time=144 ms
64 bytes from hkg07s38-in-f14.1e100.net (142.250.204.46): icmp_seq=12 ttl=128 time=128 ms
64 bytes from hkg07s38-in-f14.1e100.net (142.250.204.46): icmp_seq=13 ttl=128 time=128 ms
64 bytes from hkg07s38-in-f14.1e100.net (142.250.204.46): icmp_seq=14 ttl=128 time=141 ms
64 bytes from hkg07s38-in-f14.1e100.net (142.250.204.46): icmp_seq=15 ttl=128 time=135 ms
64 bytes from hkg07s38-in-f14.1e100.net (142.250.204.46): icmp_seq=16 ttl=128 time=130 ms
64 bytes from hkg07s38-in-f14.1e100.net (142.250.204.46): icmp_seq=17 ttl=128 time=133 ms
64 bytes from hkg07s38-in-f14.1e100.net (142.250.204.46): icmp_seq=18 ttl=128 time=142 ms
64 bytes from hkg07s38-in-f14.1e100.net (142.250.204.46): icmp_seq=19 ttl=128 time=134 ms
64 bytes from hkg07s38-in-f14.1e100.net (142.250.204.46): icmp_seq=20 ttl=128 time=137 ms
64 bytes from hkg07s38-in-f14.1e100.net (142.250.204.46): icmp_seq=21 ttl=128 time=139 ms
^C64 bytes from hkg07s38-in-f14.1e100.net (142.250.204.46): icmp_seq=22 ttl=128 time=140 ms
64 bytes from hkg07s38-in-f14.1e100.net (142.250.204.46): icmp_seq=23 ttl=128 time=121 ms
64 bytes from hkg07s38-in-f14.1e100.net (142.250.204.46): icmp_seq=24 ttl=128 time=146 ms
64 bytes from hkg07s38-in-f14.1e100.net (142.250.204.46): icmp_seq=25 ttl=128 time=136 ms
64 bytes from hkg07s38-in-f14.1e100.net (142.250.204.46): icmp_seq=26 ttl=128 time=165 ms
64 bytes from hkg07s38-in-f14.1e100.net (142.250.204.46): icmp_seq=27 ttl=128 time=176 ms
64 bytes from hkg07s38-in-f14.1e100.net (142.250.204.46): icmp_seq=28 ttl=128 time=132 ms
^C
--- youtube.com ping statistics ---
28 packets transmitted, 28 received, 0% packet loss, time 27045ms
rtt min/avg/max/mdev = 120.372/140.817/187.758/14.526 ms
                                                                    

┌──(shreyas㉿kali)-[~]
└─$ traceroute google.com
traceroute to google.com (142.250.204.110), 30 hops max, 60 byte packets
 1  192.168.29.2 (192.168.29.2)  0.227 ms  0.099 ms  0.175 ms
 2  * * *
 3  * * *
 4  * * *
 5  * * *
 6  * * *
 7  * * *
 8  * * *
 9  * * *
10  * * *
11  * * *
12  * * *
13  * * *

┌──(shreyas㉿kali)-[~]
└─$ ip a    
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:c5:88:a0 brd ff:ff:ff:ff:ff:ff
    inet 192.168.x.x/24 brd 192.168.x.x scope global dynamic noprefixroute eth0
       valid_lft 1630sec preferred_lft 1630sec
    inet6 fe80::20c:29ff:x:x/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

┌──(shreyas㉿kali)-[~]
└─$ netstat -ie                   
Kernel Interface table
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.x.x  netmask 255.255.255.0  broadcast 192.168.29.255
        inet6 fe80::20c:29ff:x:x  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:c5:88:a0  txqueuelen 1000  (Ethernet)
        RX packets 102  bytes 11285 (11.0 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 207  bytes 17053 (16.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 8  bytes 400 (400.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 8  bytes 400 (400.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        
                                                                                                       
┌──(shreyas㉿kali)-[~]
└─$ netstat -r 
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
default         192.168.29.2    0.0.0.0         UG        0 0          0 eth0
192.168.29.0    0.0.0.0         255.255.255.0   U         0 0          0 eth0


Transporting Files over a Network

[me@linuxbox ~]$ ftp fileserver
Connected to fileserver.localdomain.
220 (vsFTPd 2.0.1)
Name (fileserver:me): anonymous
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> cd pub/cd_images/ubuntu-18.04
250 Directory successfully changed.
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
-rw-rw-r--    1 500      500      733079552 Apr 25 03:53 ubuntu-18.04-desktop-amd64.iso
226 Directory send OK.
ftp> lcd Desktop
Local directory now /home/me/Desktop
ftp> get ubuntu-18.04-desktop-amd64.iso
local: ubuntu-18.04-desktop-amd64.iso remote: ubuntu-18.04-desktop-amd64.iso
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for ubuntu-18.04-desktop-amd64.iso (733079552 bytes).
226 File send OK.
733079552 bytes received in 68.56 secs (10441.5 kB/s)
ftp> bye
Command Meaning
ftp fileserver Invoke the ftp program and have it connect the FTP server fileserver
anonymous Login name. After the login prompt, a password prompt will appear. Some servers will accept a blank password; others will require a password in the form of an email address. In that case, try something like user@example.
cd change directory
ls list directory
lcd Desktop Change the directory on the local system to ~/Desktop. In the example, the ftp program was invoked when the working directory was ~. This command changes the working directory to ~/Desktop.
get transfer file from remote server to local system
bye Log off the remote server and end the ftp program session. The commands quit and exit may also be used.

[me@linuxbox ~]$ wget http://linuxcommand.org/index.php
--11:02:51--  http://linuxcommand.org/index.php
           => `index.php'
Resolving linuxcommand.org... 66.35.250.210
Connecting to linuxcommand.org|66.35.250.210|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]

    [ <=>                                 ] 3,120         --.--K/s

11:02:51 (161.75 MB/s) - `index.php' saved [3120]

[me@linuxbox ~]$ ssh remote-sys
The authenticity of host 'remote-sys (192.168.1.4)' can't be established.
RSA key fingerprint is 41:ed:7a:df:23:19:bf:3c:a5:17:bc:61:b3:7f:d9:bb.
Are you sure you want to continue connecting (yes/no)?

[me@linuxbox ~]$ scp remote-sys:document.txt .
me@remote-sys's password:
document.txt                           100% 5581     5.5KB/s   00:00
[me@linuxbox ~]$
[me@linuxbox ~]$ sftp remote-sys
Connecting to remote-sys...
me@remote-sys's password:
sftp> ls
ubuntu-8.04-desktop-i386.iso
sftp> lcd Desktop
sftp> get ubuntu-8.04-desktop-i386.iso
Fetching /home/me/ubuntu-8.04-desktop-i386.iso to ubuntu-8.04-desktop-i386.iso
/home/me/ubuntu-8.04-desktop-i386.iso 100%  699MB   7.4MB/s   01:35
sftp> bye

𝐒𝐞𝐚𝐫𝐜𝐡𝐢𝐧𝐠 𝐟𝐨𝐫 𝐟𝐢𝐥𝐞𝐬


File type Description
b Block special device file
c Character special device file
d Directory
f Regular file
l Symbolic link
Character Unit
b 512-byte blocks. This is default if no unit is specified.
c Bytes
w 2-byte words
k Kilobytes (units of 1,024 bytes)
M Megabytes (units of 1,048,576 bytes)
c Gigabytes (units of 1,073,741,824 bytes)

find ~ -type f -name 'foo*' -print | xargs ls -l
-rwxr-xr-x 1 me   me 224 2007-10-29 18:44 /home/me/bin/foo
-rw-r--r-- 1 me   me   0 2016-09-19 12:53 /home/me/foo.txt

Remaining: