Filename | Basic Linux Commands |
Permission | rw-r--r-- |
Author | Unknown |
Date and Time | 12/15/2016 |
Label | Basic Tutorials |
Action |
Institute For Ethical Hacking Course and Ethical Hacking Training in Pune - India
Sadik Shaikh | Extreme Hacking | Cyber Suraksha Abhiyan
Basic Linux Commands:
man
Linux "manual" pages, describing in detail every command, what it's options are, and what it does.
ex
$ man
What manual page do you want?
ex2
$ man ls | more
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.
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
--More--
pwd
Shows the path of the directory you are in; aka "Parent Working Directory".
ex
$ pwd
/home/cisc0ninja
ls (ls -al shows hidden files too)
Same as dir, list files and folders in your current directory.
ex
$ ls
agetty.exe hwclock.exe mkfs.bfs mkfs.minix sln.exe
fsck.cramfs init.exe mkfs.cramfs mkswap.exe sysctl.exe
fsck.minix killall5.exe mkfs.exe runlevel.exe telinit
clear
Same as cls, clears you current shell's screen.
cat
Same as type, "concatenates" aka list the contents of a file "normally text files".
ex
$ cat test
test
grep
"Global Regular Expressions Parser"<---(don't ask me why I know this) is used for searching files for strings you want.
ex
$ cat hackers.txt | grep Steve
Richard Stevens
Steve Bellovin
Steve Crocker
Steve Jobs
Steve Shirley
Steve Wozniak
Steven G. Steinberg
chmod
Changes the access file attributes of a file or folder.(readonly,writable,hidden,etc...)
ex (the first number is (7) is for user, second number for group, and third for everyone else, 7=writable, 5=read&execute, 0=nothing
chmod -R 700 /home/share/mydirectory
chown
Changes the ownership file attributes of a file or folder.
ex (-R means recursive ie.. for every folder and file underneath)
chown -R cisc0ninja:localadmins /home/share
rm
Removes a file.
ex
$ rm test.txt
rmdir
Removes a directory
ex
$ rmdir test
ifconfig
(ifconfig -a)
List your network interfaces and their configuration options.
ex
shinra:/home/share# ifconfig -a | more
eth1 Link encap:Ethernet HWaddr 00:17:31:37:9b:7d
inet addr:172.30.115.75 Bcast:172.30.115.255 Mask:255.255.255.0
inet6 addr: fe80::217:31ff:fe37:9b7d/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:751482 errors:0 dropped:0 overruns:0 frame:0
TX packets:743923 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:496898734 (473.8 MiB) TX bytes:180162903 (171.8 MiB)
Interrupt:16
ssh
Upgraded version of telnet with an added bonus of encryption and secure copying capabilities.
ex
cisc0ninja@shinra:~$ ssh -l cisc0ninja argos.soldierx.com
Password:
§+++++++++++++++++++++++++++++++++++++++++++++++§
]|[ [-=- SOLDIERX.COM Presents -=-] ]|[
cisc0ninja@argos:~$
tar
Linux zip utility to zip and unzip files.
ex
$ tar -zxvf dnsenum1.1.tar.gz
belgacom.be_ips.txt
dnsenum.pl
dns.txt
README.txt
sort
Sorts the content inside of a document. (alpha-numerically)
ex
$ sort hackers-orig.txt | uniq >> hackers.txt
uniq
Removes duplicate entries in a file.
ex
$ sort hackers-orig.txt | uniq >> hackers.txt
mv
Moves a file.
ex
$ mv test /tmp
mount
Makes a connected device (hard drive, flash drive, etc..) accessible to you and the system whether it's mounted as readonly or writable is up to you.
It can also be used (as below) to show what devices are mounted, how, and where.
ex
shinra:/home/share# mount
/dev/md2 on / type ext3 (rw,errors=remount-ro)
tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
procbususb on /proc/bus/usb type usbfs (rw)
udev on /dev type tmpfs (rw,mode=0755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
/dev/md0 on /boot type ext3 (rw)
nfsd on /proc/fs/nfsd type nfsd (rw)
df (or df -h)
shows file system usage
ex
$ df -h
Filesystem Size Used Avail Use% Mounted on
C:\cygwin\bin 75G 63G 13G 84% /usr/bin
C:\cygwin\lib 75G 63G 13G 84% /usr/lib
C:\cygwin 75G 63G 13G 84% /
c: 75G 63G 13G 84% /cygdrive/c
ps (ps -aux) or top
used for showing amount of processing power and memory each service/application is using.
ex
top - 02:35:57 up 8:07, 2 users, load average: 0.00, 0.00, 0.00
Tasks: 6 total, 2 running, 4 sleeping, 0 stopped, 0 zombie
Cpu(s): 2.7% user, 4.8% system, 0.0% nice, 92.5% idle
Mem: 1015152k total, 609300k used, 405852k free, 0k buffers
Swap: 1523712k total, 71080k used, 1452632k free, 0k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
11392 cisc0ninja 8 0 2388 2860 40 R 2.9 0.3 0:00.09 top
1712 SYSTEM 8 0 2028 2292 76 S 0.0 0.2 0:00.15 cygrunsrv
2220 SYSTEM 8 0 2572 3692 40 S 0.0 0.4 0:00.15 sshd
3952 cisc0ninja 8 0 2860 356 12 R 0.0 0.0 0:01.12 bash
2344 cisc0ninja 8 0 2924 1884 40 S 0.0 0.2 0:01.06 bash
244 cisc0ninja 8 0 2640 132 0 S 0.0 0.0 0:00.18 ssh
vi/vim
A text editor for command line, very powerful, takes some time to getting use to.
note: (to exit out of vi/vim press esc a couple of times then the shift and colon key "same time", then type q! "not at same time";)
(if you want to save make it wq!)
ex
vi test.pl
MORE OPERATORS!!!
$
Used to define a variable or constant
ex
$ echo $SHELL
/bin/bash
--help
Gives further information on a command, such as what options are available for use with that command.
ex
$ cat --help
Usage: cat [OPTION] [FILE]...
Concatenate FILE(s), or standard input, to standard output.
-A, --show-all equivalent to -vET
-b, --number-nonblank number nonblank output lines
-e equivalent to -vE
-E, --show-ends display $ at end of each line
-n, --number number all output lines
-s, --squeeze-blank never more than one single blank line
-t equivalent to -vT
-T, --show-tabs display TAB characters as ^I
-u (ignored)
-v, --show-nonprinting use ^ and M- notation, except for LFD and TAB
--help display this help and exit
--version output version information and exit
With no FILE, or when FILE is -, read standard input.
Examples:
cat f - g Output f's contents, then standard input, then g's contents.
cat Copy standard input to standard output.
www.extremehacking.org
Cyber Suraksha Abhiyan, CEHv9, CHFI, ECSAv9, CAST, ENSA, CCNA, CCNA SECURITY, MCITP, RHCE, CHECKPOINT, ASA FIREWALL, VMWARE, CLOUD, ANDROID Hacking, IPHONE Hacking, NETWORKING HARDWARE,TRAINING INSTITUTE IN PUNE, Certified Ethical Hacking,Center For Advanced Security Training in India, ceh v9 course in Pune-India, ceh certification in pune-India, ceh v9 training in Pune-India, Ethical Hacking Course in Pune-India
Sadik Shaikh | Extreme Hacking | Cyber Suraksha Abhiyan
Basic Linux Commands:
man
Linux "manual" pages, describing in detail every command, what it's options are, and what it does.
ex
$ man
What manual page do you want?
ex2
$ man ls | more
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.
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
--More--
pwd
Shows the path of the directory you are in; aka "Parent Working Directory".
ex
$ pwd
/home/cisc0ninja
ls (ls -al shows hidden files too)
Same as dir, list files and folders in your current directory.
ex
$ ls
agetty.exe hwclock.exe mkfs.bfs mkfs.minix sln.exe
fsck.cramfs init.exe mkfs.cramfs mkswap.exe sysctl.exe
fsck.minix killall5.exe mkfs.exe runlevel.exe telinit
clear
Same as cls, clears you current shell's screen.
cat
Same as type, "concatenates" aka list the contents of a file "normally text files".
ex
$ cat test
test
grep
"Global Regular Expressions Parser"<---(don't ask me why I know this) is used for searching files for strings you want.
ex
$ cat hackers.txt | grep Steve
Richard Stevens
Steve Bellovin
Steve Crocker
Steve Jobs
Steve Shirley
Steve Wozniak
Steven G. Steinberg
chmod
Changes the access file attributes of a file or folder.(readonly,writable,hidden,etc...)
ex (the first number is (7) is for user, second number for group, and third for everyone else, 7=writable, 5=read&execute, 0=nothing
chmod -R 700 /home/share/mydirectory
chown
Changes the ownership file attributes of a file or folder.
ex (-R means recursive ie.. for every folder and file underneath)
chown -R cisc0ninja:localadmins /home/share
rm
Removes a file.
ex
$ rm test.txt
rmdir
Removes a directory
ex
$ rmdir test
ifconfig
(ifconfig -a)
List your network interfaces and their configuration options.
ex
shinra:/home/share# ifconfig -a | more
eth1 Link encap:Ethernet HWaddr 00:17:31:37:9b:7d
inet addr:172.30.115.75 Bcast:172.30.115.255 Mask:255.255.255.0
inet6 addr: fe80::217:31ff:fe37:9b7d/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:751482 errors:0 dropped:0 overruns:0 frame:0
TX packets:743923 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:496898734 (473.8 MiB) TX bytes:180162903 (171.8 MiB)
Interrupt:16
ssh
Upgraded version of telnet with an added bonus of encryption and secure copying capabilities.
ex
cisc0ninja@shinra:~$ ssh -l cisc0ninja argos.soldierx.com
Password:
§+++++++++++++++++++++++++++++++++++++++++++++++§
]|[ [-=- SOLDIERX.COM Presents -=-] ]|[
cisc0ninja@argos:~$
tar
Linux zip utility to zip and unzip files.
ex
$ tar -zxvf dnsenum1.1.tar.gz
belgacom.be_ips.txt
dnsenum.pl
dns.txt
README.txt
sort
Sorts the content inside of a document. (alpha-numerically)
ex
$ sort hackers-orig.txt | uniq >> hackers.txt
uniq
Removes duplicate entries in a file.
ex
$ sort hackers-orig.txt | uniq >> hackers.txt
mv
Moves a file.
ex
$ mv test /tmp
mount
Makes a connected device (hard drive, flash drive, etc..) accessible to you and the system whether it's mounted as readonly or writable is up to you.
It can also be used (as below) to show what devices are mounted, how, and where.
ex
shinra:/home/share# mount
/dev/md2 on / type ext3 (rw,errors=remount-ro)
tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
procbususb on /proc/bus/usb type usbfs (rw)
udev on /dev type tmpfs (rw,mode=0755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
/dev/md0 on /boot type ext3 (rw)
nfsd on /proc/fs/nfsd type nfsd (rw)
df (or df -h)
shows file system usage
ex
$ df -h
Filesystem Size Used Avail Use% Mounted on
C:\cygwin\bin 75G 63G 13G 84% /usr/bin
C:\cygwin\lib 75G 63G 13G 84% /usr/lib
C:\cygwin 75G 63G 13G 84% /
c: 75G 63G 13G 84% /cygdrive/c
ps (ps -aux) or top
used for showing amount of processing power and memory each service/application is using.
ex
top - 02:35:57 up 8:07, 2 users, load average: 0.00, 0.00, 0.00
Tasks: 6 total, 2 running, 4 sleeping, 0 stopped, 0 zombie
Cpu(s): 2.7% user, 4.8% system, 0.0% nice, 92.5% idle
Mem: 1015152k total, 609300k used, 405852k free, 0k buffers
Swap: 1523712k total, 71080k used, 1452632k free, 0k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
11392 cisc0ninja 8 0 2388 2860 40 R 2.9 0.3 0:00.09 top
1712 SYSTEM 8 0 2028 2292 76 S 0.0 0.2 0:00.15 cygrunsrv
2220 SYSTEM 8 0 2572 3692 40 S 0.0 0.4 0:00.15 sshd
3952 cisc0ninja 8 0 2860 356 12 R 0.0 0.0 0:01.12 bash
2344 cisc0ninja 8 0 2924 1884 40 S 0.0 0.2 0:01.06 bash
244 cisc0ninja 8 0 2640 132 0 S 0.0 0.0 0:00.18 ssh
vi/vim
A text editor for command line, very powerful, takes some time to getting use to.
note: (to exit out of vi/vim press esc a couple of times then the shift and colon key "same time", then type q! "not at same time";)
(if you want to save make it wq!)
ex
vi test.pl
MORE OPERATORS!!!
$
Used to define a variable or constant
ex
$ echo $SHELL
/bin/bash
--help
Gives further information on a command, such as what options are available for use with that command.
ex
$ cat --help
Usage: cat [OPTION] [FILE]...
Concatenate FILE(s), or standard input, to standard output.
-A, --show-all equivalent to -vET
-b, --number-nonblank number nonblank output lines
-e equivalent to -vE
-E, --show-ends display $ at end of each line
-n, --number number all output lines
-s, --squeeze-blank never more than one single blank line
-t equivalent to -vT
-T, --show-tabs display TAB characters as ^I
-u (ignored)
-v, --show-nonprinting use ^ and M- notation, except for LFD and TAB
--help display this help and exit
--version output version information and exit
With no FILE, or when FILE is -, read standard input.
Examples:
cat f - g Output f's contents, then standard input, then g's contents.
cat Copy standard input to standard output.
www.extremehacking.org
Cyber Suraksha Abhiyan, CEHv9, CHFI, ECSAv9, CAST, ENSA, CCNA, CCNA SECURITY, MCITP, RHCE, CHECKPOINT, ASA FIREWALL, VMWARE, CLOUD, ANDROID Hacking, IPHONE Hacking, NETWORKING HARDWARE,TRAINING INSTITUTE IN PUNE, Certified Ethical Hacking,Center For Advanced Security Training in India, ceh v9 course in Pune-India, ceh certification in pune-India, ceh v9 training in Pune-India, Ethical Hacking Course in Pune-India