Reproduced shell Command 73 article

Source: Internet
Author: User
Tags gz file md5 hash egrep

1. Check if the remote port is open for bash:

echo >/dev/tcp/8.8.8.8/53 && echo "open"

2. Turn the process into the background:

Ctrl + z

3. Transfer the process to the foreground:

fg

4. Generates a random hexadecimal number, where n is the number of characters:

openssl rand -hex n

5. Execute a command in a file in the current shell:

source /home/user/file.name

6. Intercept the first 5 characters:

${variable:0:5}

7.SSH Debug Mode:

ssh -vvv user@ip_address

8.SSH with PEM key:

ssh user@ip_address -i key.pem

9. Crawl the complete Site directory structure with wget and store it in a local directory:

"index.html*" http://hostname/ -P /home/user/dirs

10. Create more than one directory at a time:

mkdir -p /home/user/{test,test1,test2}

11. List the process tree that includes the child processes:

ps axwef

12. Create the War file:

jar -cvf name.war file

13. Test HDD Write Speed:

if=/dev/zero of=/tmp/output.img bs=8k count=256k; rm -rf /tmp/output.img

14. Test Drive Read Speed:

hdparm -Tt /dev/sda

15. Get the MD5 hash of the text:

"text" | md5sum

16. Check the XML format:

xmllint --noout file.xml

17. Extract the tar.gz into the new directory:

tar zxvf package.tar.gz -C new_dir

18. Get the HTTP header information using curl:

curl -I http://www.example.com

19. Modify the timestamp (YYMMDDHHMM) of the file or directory:

0712250000 file

20. Perform an FTP download with the wget command:

wget -m ftp://username:password@hostname

21. Generate a random password (the example is 16 characters in length):

LANG=c < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-16};echo;

22. Quickly back up a file:

cp some_file_name{,.bkp}

23. Access the Windows shared directory:

"DOMAIN\user" //dc.domain.com/share/test/dir

24. The command in the execution history (this is line 100th):

!100

25. Unzip:

unzip package_name.zip -d dir_name

26. Enter multiple lines of text (CTRL + D exit):

cat > test.txt

27. Create an empty file or empty an existing file:

\> test.txt

28. Sync time with Ubuntu NTP server:

ntpdate ntp.ubuntu.com

29. Display all TCP4 listening ports with netstat:

‘{print $4}‘ | cut -f2 -d: | grep -o ‘[0-9]*‘

30.qcow2 image File Conversion:

qemu-img convert -f qcow2 -O raw precise-server-cloudimg-amd64-disk1.img \precise-server-cloudimg-amd64-disk1.raw

31. Run the file repeatedly, showing its output (by default, 2 seconds):

watch ps -ef

32. List of all users:

getent passwd

33.Mount root in Read/write mode:

mount -o remount,rw /

34. Mount a directory (this is a case where links cannot be used):

mount --bind /source /destination

35. Dynamically update DNS server:

86400 A $IPsendEOF

36. Recursive grep all directories:

"some_text" /path/to/dir

37. List the top 10 largest files:

‘{ if($7 > 1048576) print $7/1048576 "MB "$9 }‘ | sort -n -u | tail

38. Show remaining memory (MB):

‘/[0-9]/{ print $4" MB" }‘

39. Open vim and jump to the end of the file:

vim + some_file_name

40.Git clones the specified branch (master):

git clone git@github.com:name/app.git -b master

41.Git Switch to another branch (develop):

git checkout develop

42.Git Delete Branch (myfeature):

git branch -d myfeature

43.Git Delete Remote Branch

git push origin :branchName

44.Git Push the new branch to the remote server:

git push -u origin mynewfeature

45. Last Cat command in print history:

!cat:p

46. Last cat command in the Run history:

!cat

47. Find all the empty empty directories under/home/user:

1 -type d -empty

48. Get the contents of the 第50-60 line in the Test.txt file:

‘50,60p‘

49. Run the last command (if the last command is Mkdir/root/test, the following will run: sudo mkdir/root/test):

sudo !!

50. Create temporary RAM file System –ramdisk (create/tmpram directory first):

mount -t tmpfs tmpfs /tmpram -o size=512m

51.Grep whole words:

"name" test.txt

52. Append text to a file in case you need to elevate your privileges:

"some text" | sudo tee -a /path/file

53. List all kill signal parameters:

kill -l

54. Prohibit logging of the last session in bash history:

kill -9 $$

55. Scan the network for open ports:

8081 172.20.0.0/16

56. Set up git email:

git config --global user.email "[email protected]"

57.To sync with Master If you have unpublished commits:

git pull --rebase origin master

58. Move all files with "TXT" in the file name into the/home/user directory:

"*txt*" -exec mv -v {} /home/user \;

59. Display the file in rows and lines:

paste test.txt test1.txt

Progress bar in 60.shell:

pv data.log

61. Use Netcat to send data to Graphite server:

"hosts.sampleHost 10 `date +%s`" | nc 192.168.200.2 3000

62. Convert Tabs to spaces:

expand test.txt > test1.txt

63.Skip Bash History:

< space >cmd

64. Go to the previous working directory:

cd -

65. Split the large volume tar.gz file (each 100MB) and merge it back in:

100m /path/to/large/archive /path/to/output/filescat files* > archive

66. Use Curl to get the HTTP status code:

"%{http_code}\\n" www.example.com -o /dev/null

67. Set the root password to enhance MySQL security installation:

/usr/bin/mysql_secure_installation

68. When Ctrl + C is not good to make:

Ctrl + \

69. Get the file owner:

stat -c %U file.txt

70.block Device List:

lsblk -f

71. Locate the file with a space at the end of the file name:

find . -type f -exec egrep -l " +$" {} \;

72. Find the file with the tab indent in the filename

find . -type f -exec egrep -l $‘\t‘ {} \;

73. Print a horizontal line with "=": Select Copy to put in notes

‘%100s\n‘ | tr ‘ ‘ =

Shell commands reproduced in 73 article

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.