One, directory switch command
On Windows, you can use the graphical user interface (GUI) or mouse to switch to a directory. On Linux, you must run the CD command to switch to a directory.
CD usr switch to the usr directory in this directory
cd .. / Switch to the previous directory
CD/Switch to the system root directory
CD ~ Switch to the user home directory
CD – Switch to the previous directory
Two, directory operation commands (add, delete, change and check)
Directory operation commands (add, delete, modify, and search)
1. Run the mkdir directory name command
Example: mkdir test under the root directory/produces a test query directory under the root directory /
2. Run ls [-al] parent directory
Example: If you use ls under the root directory /, you can see all directories and files under this directory
Example: Using ls -a under the root directory /, you can see all files and directories under this directory, including hidden ones
Example: Using ls -l under the root directory /, you can see details about all directories and files under this directory
Note: ls -l can be shortened to ll
3. Find the catalog (search)
Command: find directory parameters
Example: find /root -name ‘test*’
4. Change directory name (change)
Command: mv directory name New directory name
For example, run the mv oldTest newTest command to modify the oldTest directory in the test directory
Note: the syntax of MV can not only rename directories, but also rename various files, compressed packages, etc
5. Move directory location — cut (change)
Command: mv directory name New location of the directory
Example: Cut the newTest directory under test to /usr using mv newTest /usr
Note: the MV syntax allows you to cut not only directories but also files and compressed packages
6. Copy directory (change)
Command: cp -r Directory name Target directory copy location —–r indicates recursive copy
Example: Copy newTest under /usr to test under the root directory and run cp -r /usr/newtest/test
Note: the cp command can not only copy directories but also files, compressed packages, etc., copy files and compressed packages without writing -r recursion
7. Delete directory (delete)
Command: rm [-rf] Directory
Example: Delete newTest in /usr and run rm -r newTest in /usr
Example: To delete newTest under /test without asking for forcible deletion, run rm -rf newTest under /test
Note: Rm can not only delete directories, but also delete other files or compressed packages. In order to enhance your memory, you can directly use rm -rf directory/file/compressed package to delete any directory or file
8. File creation (add)
Command: touch file name —– Empty file
Example: Create an empty file touch aaA.txt in the test directory
9. File viewing (searching)
Run the cat/more/less/tail file command
For example, run cat to view the /etc/sudo.conf file. Only the last screen is displayed
For example, run the more command to view the /etc/sudo.conf file to display the percentage, press Enter to go to the next line, space to the next page, and q to exit the file
For example, use less to view the /etc/sudo.conf file. You can use PgUp and PgDn on the keyboard to scroll up and down
Example: Use tail -10 to view the last 10 lines of the /etc/sudo.conf file, Ctrl+C ends
Note: Run the tail -f command to dynamically monitor a file. For example, the Tomcat log file changes as the program runs. You can run the tail -f catalina-2016-11-11.log command to monitor the file changes
10. Modify the contents of the file (modify)
Command: vim file
Example: Edit the aaa. TXT file under /test and use vim aaa.txt
However, you cannot edit the file at this time because you are in command mode. Press the keyboard I/A/O to enter the editing mode and then you can edit the file. After editing, press Esc to return to command mode
At this point, although the file has been edited but not saved, you need to enter a colon: to enter the bottom line mode, enter wq under the bottom line mode to write content and exit, that is, save; The input q! Indicates forcibly exits without saving.
Conclusion:
Vim editor is a powerful component in Linux, is a strengthened version of the VI editor, VIM editor commands and shortcuts have a lot of, but here is not a description, we do not need to study very thoroughly, using VIM to edit and modify the file will basically use it.
About viM use process:
In real development, the main purpose of using the Vim editor is to modify configuration files
Vim file — — — — — — — — — — – > > enter the file command mode — — — — — – > press I to enter edit mode — — — — — — — — — — – > edit file > press Esc to enter the bottom line — — — — — > input: wq/q!
11. Deleting files (Delete)
Delete the same directory: remember rm -rf file
Operation commands for compressing files Package and compress files In Linux, packages usually end in. Tar, and compression commands end in. Gz.
In most cases, the file is packaged and compressed together. The file name extension is usually.tar.gz.
Run the tar -zcvf command to package compressed file name The file to be compressed
Z: uses the gzip compression command to compress data
C: Package the files
V: Displays the running process
F: Specify the file name
Example: Package and compress all files in /test. The compressed package name is xxx.tar.gz
tar -zcvf xxx.tar.gz aaa.txt bbb.txt ccc.txt
Or: tar -zcvf xxx.tar.gz /test/*
12. Decompress the package (key)
Run the tar [-xvf] command to compress the file
X: indicates decompression
For example, decompress xxx.tar.gz in /test to tar -xvf XXX.tar. gz in the current directory
Example: Decompress xxx.tar.gz under /test to the root directory /usr
Tar -xvf xxx.tar.gz -c /usr——C indicates the specified location for decompressing files
Last line mode closes the file
:q exit :wq Save and exit :q! Do not save and exit :w Save :w! To saveCopy the code
13. Other commands
Displays the current location PWD
2. Search commands
Command: grep String File to search for
Example: Search for lines in /usr/sudu.conf that contain the string to
Example: Search the /usr/sudu.conf file for the line to that contains the string to to to be highlighted
Third, Linux permission command
Permission is an important concept in Linux. Each file or directory has a permission. You can run the ls -l command to view the permission of a file or directory in a directory
Example: ls -l in a random directory
The information in the first column is explained as follows:
Type of file:
D: indicates a directory
– : indicates a file
L: stands for link (think of it as a shortcut in Windows)
The last nine digits are divided into three groups. Each group of three digits represents the rights of the owner, the rights of the user in the same group as the current user, and the rights of other users
R: indicates that the permission is readable. R can also be represented by 4
W: indicates that the permission is writable. W can also be represented by 2
X: indicates that the permission is executable. X can also be represented by the number 1
Run the chmod command to change the permission of a file or directory
Example: Modify the aaa. TXT file under /test to give the owner all permissions and the owner group read and write permissions.
Other users only have the read permission
chmod u=rwx,g=rw,o=r aaa.txt
The examples above can also be expressed numerically:
chmod 764 aaa.txt
Kali Linux command set
System information
Arch displays the processor architecture of the machine (1) uname -m displays the processor architecture of the machine (2) uname -r displays the kernel version in use dMIDecode -q displays the hardware system components – (SMBIOS/DMI) hdparm -i /dev/hda List the architecture features of a disk hdparm-tt /dev/sda Perform test reads on the disk cat /proc/cpuInfo Displays CPU info information cat /proc/Interrupts Displays interrupt cat Cat /proc/meminfo Uses cat /proc/swaps to check which swaps are used. Cat /proc/version Displays the kernel version. Cat /proc/net/dev displays network adapters and mounts statistics Lsusb-tv display USB device date Display system date CAL 2007 Display 2007 calendar date 041217002007.00 Set date and time – The month and day are divided into years. Clock -w Save the time change to BIOS shutdown (system shutdown, restart, and logout) shutdown -h now Shutdown system (1) init 0 Shutdown system (2) telinit 0 shutdown system (3) shutdown -h Hours :minutes & Shutting down the system at the preset time shutdown -c Canceling the shutdown at the preset time shutdown -r Now Restarting the system (1) reboot Restarting the system (2) logout
Files and Directories
CD /home Go to the ‘/home’ directory. Return to the upper directory CD… /… CD to go to the personal home directory CD ~user1 To go to the personal home directory CD – To go to the last directory PWD Display the working path ls View files in the directory ls -f View files in the directory ls -l Display details about files and directories ls -a Display hidden files ls [0-9] Display file names and directory names containing numbers tree Display tree structure of files and directories starting from the root (1) lstree Display tree structure of files and directories starting from the root (2) mkdir dir1 Create a directory called ‘dir1’ Mkdir dir1 dir2 Create both directories mkdir -p/TMP /dir1/dir2 Create a directory tree rm -f file1 Delete a file named ‘file1’ ‘rmdir dir1 Delete a directory named’ dir1 ‘ ‘ Rm -rf dir1 Delete a directory named ‘dir1’ and delete its contents rm -rf dir1 dir2 Delete two directories and their contents mv dir1 new_dir Rename/move a directory cp file1 file2 Copy a file cp dir/* . Copy all files in a directory to the current working directory cp -a/TMP /dir1. Copy a directory to the current working directory cp -a dir1 dir2 Copy a directory ln -s file1 lnk1 Create a soft link to a file or directory ln file1 lnk1 Create a physical link to a file or directory touch -t 0712250000 Outputs iconV-l list the known encodedIconV-f of a file or directory fromEncoding -t toEncoding inputFile > outputFile creates a new from the given input file by assuming it is encoded in FromEncoding and converting it to toencod.find. -maxdepth 1-name *.jpg -print-exec convert “{}” -resize 80×60 “Thumbs / {}”; batch resize files in the current directory and send them to a thumbnails directory (requires convert from Imagemagick)
File search
Find / -name file1 Searches for files and directories in the root file system starting from ‘/’. Find / -user user1 Searches for files and directories belonging to user user1. Find /home/user1-name * Find /usr/bin-type f-atime +100 Searches for the execution file that has not been used in the past 100 days find /usr/bin-type f-mtime-10 Find / -name *. RPM -exec chmod 755 ‘{}’; RPM: find / -xdev-name *. RPM: find / -xdev-name *. RPM: find / -xdev-name *. Ignore the CD drive, flash drive, and other portable devices locate *. Ps to find a file ending in ‘. Ps’ – first run the ‘updatedb’ command whereis halt to display a binary file, source code, or the location of man which halt Displays the full path to a binary or executable file
Mount a file system
Mount /dev/hda2 / MNT /hda2 Mount a disk named hda2 – Make sure the directory ‘/ MNT /hda2’ already exists. Umount /dev/hda2 Unmount a disk named hda2 – Exit the mount point ‘/ MNT /hda2’ first Fuser -km/MNT /hda2 Forcibly unmount the device when it is busy umount -n/MNT /hda2 Run the unmount operation without writing the /etc/mtab file – Useful when the file is read-only or the disk is full mount /dev/fd0/mnt /floppy Mount a floppy disk Mount /dev/cdrom/MNT /cdrom Mount a Cdrom or dvdrom mount /dev/hdc/MNT/cdRecorder Mount a CDRW or dvdrom mount /dev/hdb / MNT /cdrecorder mount a CDRW or dvdrom mount -o loop file.iso/MNT /cdrom Mount a file or ISO image file mount -t vfat /dev/hda5 / MNT /hda5 Mount a Windows FAT32 file system mount /dev/sda1 / MNT /usbdisk Mount a USB flash drive or flash memory device mount -t SMBFS -o username=user,password=pass //WinClient/share/MNT /share mounts a Windows network share
Disk space
Df -h display the list of partition is mounted ls – lSr | more arranged in size file and directory du – sh dir1-name estimate directory ‘dir1-name has used disk space’ du – sk * | sort – rn) based on size, in turn, according to the size of the files and directories RPM – q – a – qf ‘% 10 {NAME} {SIZE} t % n’ | sort – k1, 1 n based on the SIZE of the display has been installed in turn the space used by RPM package (fedora, Redhat system) dpkg-query -w-f = ‘I n s t a l l ed − s I z e; 10 t {Installed-Size; 10} t Installed – Size; 10 t {Package} n ‘| sort – k1, 1 n based on the size of the display installed deb Package used by space (ubuntu, debian system)
Users and Groups
Groupadd group_name Creates a user group groupdel group_name Deletes a user group groupmod -n new_group_name old_group_name Renames a user group useradd -c “Name Surname “-g admin -d /home/user1 -s /bin/bash user1 Create a user belonging to the admin user group useradd user1 Create a new user userdel -r user1 Delete a User (‘ -r ‘excludes the home directory) usermod -c “User FTP” -g system -d/FTP /user1 -s /bin/nologin user1 Modify the User attribute passwd Modify the password passwd user1 Change the password of a user (root only) chage -e 2005-12-31 user1 Set the validity period of the user password PWCK Check the file format and syntax of ‘/etc/passwd’ and the existence of user GRPCK check File format and syntax fixes for ‘/etc/passwd’ and existing group newgrp group_name logs into a new group to change the default group for newly created files
File permission – Use “+” to set the permission and “-” to cancel it
Ls – lh show permissions ls/TMP | pr – T5 – W $COLUMNS will be divided into terminal 5 bar shows chmod ugo + RWX directory1 all set the directory (u), group (g) and others (o) to read (r ), write (w), and execute (x) permissions chmod go-rwx directory1 Deletes the read and write execute permissions on directories of groups (G) and others (O) chown user1 file1 Changes the owner attribute of a file chown -r user1 Directory1 Changes the owner properties of a directory and all files in the directory CHGRP group1 file1 Group in which the file is changed chown user1:group1 file1 Changes the owner and group properties of a file find / -perm -u+s Lists all files in a system that use SUID control chmod u+s /bin/file1 Sets the SUID bit of a binary file – The user running the file is also granted the same permissions as the owner chmod u-s /bin/file1 Chmod g+s /home/public Sets the SGID bit of a directory – similar to SUID, Chmod g-s /home/public Disables the SGID bit of a directory chmod o+t /home/public sets the STIKY bit of a file – only allows legal owners to delete files chmod o-t /home/public Disables the STIKY bit of a directory
Special properties of the file – Use “+” to set permissions and “-” to cancel
Chattr +c file1 allows the file to be automatically compressed/uncompressed by the kernel. Chattr +d file1 During file system backup, Chattr +s file1 allows a file to be safely deleted once an application writes to the file. Chattr +s file1 Chattr +u file1 If a file is deleted, the system will allow you to restore the deleted file later. Lsattr displays special properties
Package and compress files
Bz2 unzip a file called ‘file1.bz2 ‘bzip2 file1 unzip a file called ‘file1.bz2’ gunzip file1.gz Unzip a file called ‘file1.gz ‘gzip file1 Compress a file called ‘file1 ‘gzp-9 file1 Compress rar a file1.rar test_file Create a package called’ file1.rar ‘ Also compress ‘file1’, Rar package unrar x file1.rar Decompress the rar package tar -cvf archive.tar file1 Creates an uncompressed tarball tar -cvf Archive. tar file1 file2 dir1 Creates a file containing ‘file1’, Tar displays the contents of a package. Tar -xvf archive.tar Releases a package. Tar -xvf archive.tar -c/TMP Releases the compressed package to Bz2 dir1 Create a package in bzip2 format: tar -xvfj archive.tar.bz2 Decompress a package in bzip2 format: tar -cvfz Gz dir1 Create a compressed package in gzip format. Tar -xvfz archive.tar.gz Decompress a compressed package in gzip format. Zip file1.zip create a compressed package in ZIP format Zip file1 file2 dir1 Compress several files and directories into a ZIP package. Unzip file1.zip Decompresses a ZIP package
RPM package – (Fedora, Redhat, and similar systems)
RPM Install an RPM package RPM -ivh –nodeeps package. RPM Install an RPM package and ignore dependency warnings RPM -u package. RPM Update an RPM package without changing its configuration file RPM – F package. The RPM update a sure you have installed the RPM package RPM -e package_name. RPM to remove an RPM package RPM – qa list all installed in the system of RPM package RPM – qa | grep HTTPD shows all name contains RPM -qi package_name To obtain special information about an installed package RPM -qg System Environment/Daemons to display the RPM package RPM -ql package_name of a component RPM -qc package_name Displays the list of configuration files provided by an installed RPM package. RPM -q package_name — Whatrequires Displays the list of dependencies with an RPM package RPM -q package_name –whatprovides Displays the volume occupied by an RPM package. RPM -q package_name –scripts displays scripts executed during installation or deletion – change history changelog shows a RPM package RPM – qf/etc/HTTPD/conf/HTTPD. Conf the confirmation to the file which RPM – RPM package provided by qp package. The RPM – l RPM –import /media/cdrom/RPM -gpg-key Import public KEY digital certificate RPM –checksig package. RPM Verify the integrity of an RPM package RPM -qa Gpg-pubkey Check the integrity of all installed RPM packages RPM -v package_name Check the file size, license, type, owner, group, MD5 check, and last modified time RPM -va Check all installed RPM packages in the system – Use RPM -vp with caution To identify a RPM package. The RPM package has not been installed rpm2cpio package. The RPM | cpio, extract, the make – directories bin from a RPM package run RPM – the ivh for executable files / usr/SRC/redhat/RPMS/arch/package. The RPM RPM from one source to install a build good package rpmbuild – rebuild package_name. SRC. RPM RPM from one source to build a RPM package
YUM Package Upgrader – (Fedora, RedHat and similar systems)
Install package_name yum localinstall package_name. RPM Yum update package_name yum update package_name yum update package_name yum remove Package_name Yum list Yum search package_name Yum search package_name Yum clean packages Yum clean packages Yum Clean All Deletes all cached packages and headers
DEB packages (Debian, Ubuntu, and similar systems)
DPKG -i package. Deb installation/update a deb package DPKG -r package_name deleted from the system a deb package DPKG — l display system all has been installed in the deb package DPKG -l | grep HTTPD DPKG -l package_name Specifies the name of a deb package that has been installed in your system –contents package.deb displays the list of files provided by a package that has not yet been installed. DKG -s /bin/ping confirms which deb is providing the given file
APT software tools (Debian, Ubuntu and similar systems)
Apt-get install package_name Install deb package apt-cdrom install package_name Install deb package apt-cdrom install package_name Install deb package apt-get update install deb package Apt-get upgrade Upgrade all installed software apt-get remove package_name delete a deb package from the system apt-get check Check dependent repositories correct apt-get clean Clean the cache from downloaded software packages Apt-cache search searched-package returns the name of the package containing the searched string
Viewing file Contents
Cat file1 Displays the contents of a file from the first byte forward. Tac file1 Displays the contents of a file from the last line in reverse. More file1 Displays the contents of a long file. But it allows you to perform the same reverse operation in a file as in the forward operation head-2 file1 View the first two lines of a file tail -2 file1 View the last two lines of a file tail -f /var/log/messages View the contents of a file in real time
* Text processing
The cat file1 file2… | command <> file1_in.txt_or_file1_out.txt general syntax for text manipulation using PIPE, STDIN and STDOUT cat file1 | command (sed, grep, awk, grep, etc…). > result. TXT merge a text file detailed instructions, and during the introduction to writing a new file cat file1 | command (sed, grep, awk, grep, etc…). >> result.txt To merge a file’s verbose text, Grep Aug /var/log/messages Find the keyword “Aug” in the file ‘/var/log/messages’ grep ^Aug /var/log/messages in the file Grep [0-9] /var/log/messages Select all the lines containing numbers in the /var/log/messages file grep Aug -r /var/log/* Search for the string “Aug” sed ‘s/stringa1/stringa2/g’ example. TXT replace “string1” in example. TXT with “string2” sed ‘/^KaTeX Parse Error: Expected ‘EOF’, got ‘#’ at position 48:… Sed ‘/ *#̲/d; / ^ / d ‘example. TXT from example. TXT file delete all comments and blank lines echo’ esempio | tr ‘[: lower:]’ ‘[: upper:]’ merger and cell contents sed – e ‘1 d result. TXT From the file example.txt exclude the first line sed -n ‘/stringa1/p’ to see the line sed -e ‘s/ that contains only the word’ string1 ‘ Sed −e ‘s/stringa1//g’ example. TXT removes only the word ‘string1’ from the document and keeps the rest of it. Sed −n ‘5p; sed−n’ 5p; sed−n ‘5p; 5q ‘example.txt Sed − E’s /00/0/g’ example.txt Replaces multiple zeros with single zeros cat−nfile1 Indicates the number of lines catexample.txt∣awk ‘NR//’ example.txt deletes whitespace at the end of each line Sed -e ‘s/stringa1//g’ example.txt delete only the word ‘string1’ from the file and keep all the rest of it; Sed -n ‘5p; sed -n’ 5p; sed -n ‘5p; 5 q ‘example. TXT see line 5 sed -e’ s / 00/0 / g ‘example. TXT replace multiple with a single zero zero cat cat – n file1 labeled file lines example. TXT | awk NR % 2 = =’ 1 ‘ Delete example. TXT file all even lines of the echo a b c | awk ‘{print Sed −e ‘s/stringa1//g’ example. TXT removes only the word ‘string1’ from the document and keeps the rest of it. Sed −n ‘5p; sed−n’ 5p; sed−n ‘5p; 5 q ‘example. TXT sed to see line 5 -‘ s / 00/0 / e g ‘example. TXT replace multiple zero cat – with a single zero catexample nfile1 labeled file lines. TXT ∣ awk’ NR1} ‘view line of the first column echo a b c | awk ‘{print 1,1,1,3}’ paste -d ‘+’ file1 file2 ‘paste -d’ + ‘file1 file2’ paste -d ‘+’ file1 file2 ‘ Middle with “+” to distinguish the sort file1 file2 sort the contents of two files sort file1 file2 | uniq to take out the two files and set (duplicate rows only keep a) sort file1 file2 | uniq – u delete the intersection, Leave other line sort file1 file2 | uniq – d out the intersection of two files, leaving only exists in two files at the same time files) in a comm – 1 file1 file2 compares the contents of two files to delete “file1” only contains the contents of the comm – 2 File1 file2 Compares the contents of two files and deletes only the contents contained in file2. Comm-3 file1 file2 Compares the contents of two files and deletes only the common parts of the two files
Character Settings and file format conversion
TXT Converts the format of a text file from MSDOS to UNIX unix2dos fileunix. TXT Filedos. TXT converts the format of a text file from UNIX to MSDOS Recode… HTML < page. TXT > page. The HTML to convert a text file to HTML recode – l | more show all allow conversion formats
File System Analysis
Badblocks -v /dev/hda1 Check bad magnetic blocks on disk hda1 FSCK /dev/hda1 Repair/Check the integrity of the Linux file system on disk hda1 fsck.ext2 /dev/hda1 Restore the integrity of the ext2 file system on hda1 e2fsck /dev/hda1 Restore the integrity of the ext2 file system on hda1 e2fsck -j /dev/hda1 Restore the integrity of the ext3 file system on hda1 Ext3 /dev/hda1 Repair/Check the integrity of the ext3 file system on hda1 fsck.vfat /dev/hda1 Repair/Check the integrity of the FAT file system on hda1 fsck.msdos /dev/hda1 Dosfsck /dev/hda1 Repair/check the integrity of the DOS file system on the Hda1 disk
Example Initialize a file system
MKFS /dev/hda1 Create a file system in hda1 partition mke2fs /dev/hda1 Create a Linux ext2 file system in hda1 partition mke2fs -j /dev/hda1 Create a Linux in hda1 partition MKFS -t vfat 32 -f /dev/hda1 Creates a FAT32 file system fdformat -n /dev/fd0 formats a floppy disk mkswap /dev/hda3 Creates a swap file system
SWAP file system
Mkswap /dev/hda3 Create a swap file system swapon /dev/hda3 Enable a new swap file system swapon /dev/hda2 /dev/hdb3 Enable two swap partitions
The backup
Dump-0aj -f/TMP /home0.bak /home Make a full backup of the ‘/home’ directory dump-1aj -f/TMP /home0.bak /home Make an interactive backup of the ‘/home’ directory restore -if/TMP /home0.bak Restore an interactive backup rsync-rogpav –delete /home/tmp Synchronize directories on both sides rsync-rogpav -e SSH –delete /home Ip_address :/ TMP Through the SSH channel rsync rsync-az -e SSH –delete ip_addr:/home/public /home/local Synchronize a remote directory to the local directory rsync-az through SSH and compression – e SSH — delete/home/local ip_addr: / home/public via SSH and compression to local directory synchronization to the remote directory dd bs = 1 m if = / dev/hda | gzip | SSH user @ ip_addr ‘dd of=hda.gz’ Backs up the local disk on the remote host using SSH dd if=/dev/sda of=/ TMP /file1 Backs up the disk content to a file tar -puf backup.tar /home/user Performs a pair of files Directory ‘/ home/user interactive backup operation (CD/TMP/local / && tar c.) | SSH – c user @ ip_addr’ CD/home/share / && tar x – p ‘ Via SSH to copy a directory content in the remote directory (tar c/home) | SSH – c user @ ip_addr ‘CD/home/backup – home && tar x – p via SSH in the remote directory replication tar cf a local directory – . | (cd /tmp/backup ; Tar xf -) locally copy a directory to another location, Retain the original permissions and link the find/home/user1 -name ‘. TXT ‘| xargs cp – av — target – directory = / home/backup / — parents from a directory to find and copy all to’. TXT ‘ At the end of the file to another directory, find the/var/log -name ‘. The log ‘| tar CV – files – from = – | bzip2 > the tar. The.bz2 find all’. The log ‘at the end of the file and make a bzip package dd If =/dev/hda of=/dev/fd0 bs=512 count=1 Copy the MBR (Master Boot Record) to the floppy disk dd if=/dev/fd0 of=/dev/hda bs=512 count=1 Restores MBR content from a backup already saved to floppy disk
CD
Cdrecord -v gracetime=2 dev=/dev/cdrom -eject blank= fast-force Clears the contents of a copyable CD mkisofs /dev/cdrom > cd.iso On disk to create a CD iso image file mkisofs/dev/cdrom | gzip > cd_iso. Gz on disk to create a compressed the cd-rom iso image files mkisofs -j – allow – leading – dots – R – V /cd.iso data_cd Create an ISO image file for a directory cdRecord -v dev=/dev/cdrom cd.iso Create an ISO image file gzip -dc Cd_iso. Gz | cdrecord dev = / dev/cdrom – burn a compressed the ISO image file mount -o loop CD. ISO/MNT/ISO mount an ISO image file CD, paranoia, and B Transcription from a CD tracks to wav files in CD – paranoia – “- 3” from a CD transcription track to wav file (parameters – 3) cdrecord – scanbus scan bus in order to identify the SCSI channel dd if = / dev/HDC | Md5sum Verifies the MD5SUM encoding of a device, such as a CD
The application command
Whois Domain name/IP View domain name details. Ping domain name/IP address To test whether the local host is connected to the remote host. Dig Domain name/IP for details on domain name resolution. Host -l Domain name The DNS server transmits the zone. Scanning NMAP: -SS half-open scanning TCP and SYN scanning. -sT Scans for full TCP connections. -sU UDP scanning -PS SYN packet detection (firewall detection) -PA ACK packet detection (firewall detection) -PN No ping. -n Indicates no DNS resolution. -A-O and -SV. -o Identifies the OPERATING system. -sV Service version (banner) -p Port scan. -t Time level (0-5) -il Imports scan results. -oG Displays scan results.
Operating system identification:
P0f -i eth0 -u -p Enables promiscuous mode. IP xprobe2 | domain detection of OS.
Banner for:
Nc IP port Checks whether the port is enabled. Telnet IP port Checks whether the port is enabled. Wget IP download home page. | cat index. The HTML code more show home page. Q exit.
Windows enumeration
Nmap-ss-p 139,445 IP scan Windows. CD /pentest/enumeration/ SMB-enum nbtscan -f targetIP Check netBIOS. Smbgetserverinfo -i targetIP Scan name, OS, group. Smbdumpusers -i targetIP Lists users. Smbclient -l //targetIP lists the shares.
Using the Windows:
Net Use \ ipiPC $”” /u:”” Start an empty session. Net view \ IP Displays shared information. Smbclient: smbClient -l hostName -i targetIP Enumeration share. Smbclient -l hostName/share -u “” connects with an empty user. Smbclient -l hostName -I targetIP -u admin Common user connection.
rpcclient:
Rpcclient targetIP -u “” opens an empty session. Netshareenum Enumerates shares. Enumdomusers Enumerates users. Lsaenumsid Indicates the SID of an enumeration domain. Queryuser RID Queries user information. Createdomuser creates user access.
ARP cheating:
Ettercap: nano/usr/local/etc/etter. Conf configuration file Sniff > Unified sniffing > Network interface: Eth0 > OK Set the network adapter Hosts for packet capture > Scan for Hosts (do this two times) Scan for Hosts on the network segment > Hosts list Display the host list Select the default gateway > Add to Target 1 Add hosts Select the Target > Add to Target 2 Add hosts Mitm > Arp Nutrition > remote Connections > OK Set ARP attack Start > Start Sniffing Start sniffing dsniffing SNIFFING NETWORK adapters eavesdrop login user passwords urlsnarf-i eth0 Sniff HTTP request MSgsnarf-i eth0 sniff chat content of the chat software Driftnet – I eth0 Network management sniffing for pictures, audio.
DNS cheating:
Nano/usr/local/share/ettercap/etter. DNS edit configuration files Plugins > Manage the Plugins > dns_spoof setup DNS cheat Mitm > Arp poisoning > Sniff Remote connections > OK Set ARP Start > Start Sniffing Start attack
Adventurous:
CD/pentest/exploits/exploits – db into cat sploitlist. TXT | grep -i [exploits] query requires a loophole in the cat exploits | grep “# include” check the running environment The cat sploitlist. TXT | grep -i exploits | | “” cut – d – f1 xargs grep sys | |” : “the cut – d – f1 sort – u only reserve the code can run under Linux
Metasploit:
/ MSfWeb Web interface 127.0.0.1:55555./ msfConsole Console help under the character show display options search Search name use Use vulnerability show options Display options set Set options show payloads Display device set PAYLOAD Set device show options Display options set Settings show targets Display TARGET (OS version) set TARGET Set the TARGET version Exploits start Vulnerability attack session-l List session session-i Select session session-k End the session Z Put the session in the background C End the session JOBS List vulnerability run work jobs-k End a vulnerability run work show Auxiliary Display Auxiliary module use Auxiliary module set Set options run Run the module scanner/ SMB /version Scan the system version scanner/ MSSQL/MSSQL_ping Tests whether the MSSQL is online Scanner/MSSQL/mSSQL_login Test login (violence or dictionary) Attacker behind firewall: bind shell forward Target behind firewall: Reverse shell Use this command if you do not know DOS: db_import_nessus_nbe Loads nessus’ scan results db_import_nmap_xml loads Nmap’s scan results
Automated attack flow:
cd /pentest/exploit/framework3 ./msfconsole load db_sqlite3 db_destroy pentest db_create pentest db_nmap targetIP