LoginSignup
5
3

More than 3 years have passed since last update.

linux commands

Last updated at Posted at 2014-10-19

trouble shooting

uptime
dmesg | tail
vmstat 1
mpstat -P ALL 1
pidstat 1
iostat -xz 1
free -m
sar -n DEV 1
sar -n TCP,ETCP 1
top

curl

request by digest auth

curl --anyauth --user username:password https://XXXX.com

check https with curl's verbose mode

➜  ~ curl -vI https://www.google.co.jp
* Rebuilt URL to: https://www.google.co.jp/
*   Trying 216.58.197.227...
* Connected to www.google.co.jp (216.58.197.227) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
* Server certificate: *.google.com
* Server certificate: Google Internet Authority G2
* Server certificate: GeoTrust Global CA
> HEAD / HTTP/1.1
> Host: www.google.co.jp
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Date: Sat, 10 Sep 2016 06:33:59 GMT
Date: Sat, 10 Sep 2016 06:33:59 GMT
< Expires: -1
Expires: -1
< Cache-Control: private, max-age=0
Cache-Control: private, max-age=0
< Content-Type: text/html; charset=Shift_JIS
Content-Type: text/html; charset=Shift_JIS
< P3P: CP="This is not a P3P policy! See https://www.google.com/support/accounts/answer/151657?hl=en for more info."
P3P: CP="This is not a P3P policy! See https://www.google.com/support/accounts/answer/151657?hl=en for more info."
< Server: gws
Server: gws
< X-XSS-Protection: 1; mode=block
X-XSS-Protection: 1; mode=block
< X-Frame-Options: SAMEORIGIN
X-Frame-Options: SAMEORIGIN
< Set-Cookie: NID=86=yKp5vsy1qvf4SSViKxvUBYCEuY6tAsRQwHTc1u_0lpTwhMbujmeMoXvxC3i3pZX28nFW7YAP1FSGV-0UnwYlvGUhpRpQTfV1Iyt1IXFmHquRn9zZaYSI_XWijd-efCzi; expires=Sun, 12-Mar-2017 06:33:59 GMT; path=/; domain=.google.co.jp; HttpOnly
Set-Cookie: NID=86=yKp5vsy1qvf4SSViKxvUBYCEuY6tAsRQwHTc1u_0lpTwhMbujmeMoXvxC3i3pZX28nFW7YAP1FSGV-0UnwYlvGUhpRpQTfV1Iyt1IXFmHquRn9zZaYSI_XWijd-efCzi; expires=Sun, 12-Mar-2017 06:33:59 GMT; path=/; domain=.google.co.jp; HttpOnly
< Alt-Svc: quic=":443"; ma=2592000; v="36,35,34,33,32"
Alt-Svc: quic=":443"; ma=2592000; v="36,35,34,33,32"
< Transfer-Encoding: chunked
Transfer-Encoding: chunked
< Accept-Ranges: none
Accept-Ranges: none
< Vary: Accept-Encoding
Vary: Accept-Encoding

<
* Connection #0 to host www.google.co.jp left intact
➜  ~

request to specific ip address with specific hostname

curl -vI -XGET https://awesomesite.net --resolv catdog.net:443:127.0.0.1

openssl

show available cipher suite

openssl ciphers -v

find

find pdf extension files with case-insensitive and move desktop_image directory

find . -iname '*.pdf' -exec mv {} desktop_image \;

openssl

create self-signed certificate

http://www.akadia.com/services/ssh_test_certificate.html
https://www.digitalocean.com/community/tutorials/how-to-create-a-ssl-certificate-on-nginx-for-ubuntu-12-04

apt-get

install package

toripiyo@toripiyo-desktop:/var/log$ sudo apt-get install openssh-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  libck-connector0 ncurses-term openssh-sftp-server ssh-import-id
Suggested packages:
  rssh molly-guard monkeysphere
The following NEW packages will be installed:
  libck-connector0 ncurses-term openssh-server openssh-sftp-server
  ssh-import-id
0 upgraded, 5 newly installed, 0 to remove and 17 not upgraded.
Need to get 616 kB of archives.
After this operation, 3,420 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://jp.archive.ubuntu.com/ubuntu/ trusty/main libck-connector0 amd64 0.4.5-3.1ubuntu2 [10.5 kB]
Get:2 http://jp.archive.ubuntu.com/ubuntu/ trusty/main ncurses-term all 5.9+20140118-1ubuntu1 [243 kB]
Get:3 http://jp.archive.ubuntu.com/ubuntu/ trusty/main openssh-sftp-server amd64 1:6.6p1-2ubuntu1 [34.1 kB]
Get:4 http://jp.archive.ubuntu.com/ubuntu/ trusty/main openssh-server amd64 1:6.6p1-2ubuntu1 [319 kB]
Get:5 http://jp.archive.ubuntu.com/ubuntu/ trusty/main ssh-import-id all 3.21-0ubuntu1 [9,624 B]
Fetched 616 kB in 0s (674 kB/s)          
Preconfiguring packages ...
Selecting previously unselected package libck-connector0:amd64.
(Reading database ... 223483 files and directories currently installed.)
Preparing to unpack .../libck-connector0_0.4.5-3.1ubuntu2_amd64.deb ...
Unpacking libck-connector0:amd64 (0.4.5-3.1ubuntu2) ...
Selecting previously unselected package ncurses-term.
Preparing to unpack .../ncurses-term_5.9+20140118-1ubuntu1_all.deb ...
Unpacking ncurses-term (5.9+20140118-1ubuntu1) ...
Selecting previously unselected package openssh-sftp-server.
Preparing to unpack .../openssh-sftp-server_1%3a6.6p1-2ubuntu1_amd64.deb ...
Unpacking openssh-sftp-server (1:6.6p1-2ubuntu1) ...
Selecting previously unselected package openssh-server.
Preparing to unpack .../openssh-server_1%3a6.6p1-2ubuntu1_amd64.deb ...
Unpacking openssh-server (1:6.6p1-2ubuntu1) ...
Selecting previously unselected package ssh-import-id.
Preparing to unpack .../ssh-import-id_3.21-0ubuntu1_all.deb ...
Unpacking ssh-import-id (3.21-0ubuntu1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Processing triggers for ureadahead (0.100.0-16) ...
Processing triggers for ufw (0.34~rc-0ubuntu2) ...
Setting up libck-connector0:amd64 (0.4.5-3.1ubuntu2) ...
Setting up ncurses-term (5.9+20140118-1ubuntu1) ...
Setting up openssh-sftp-server (1:6.6p1-2ubuntu1) ...
Setting up openssh-server (1:6.6p1-2ubuntu1) ...
Creating SSH2 RSA key; this may take some time ...
Creating SSH2 DSA key; this may take some time ...
Creating SSH2 ECDSA key; this may take some time ...
Creating SSH2 ED25519 key; this may take some time ...
ssh start/running, process 30239
Setting up ssh-import-id (3.21-0ubuntu1) ...
Processing triggers for libc-bin (2.19-0ubuntu6.3) ...
Processing triggers for ureadahead (0.100.0-16) ...
Processing triggers for ufw (0.34~rc-0ubuntu2) ...

downgrade package

toripiyo@toripiyo-desktop:/var/log$ sudo apt-get install openssh-client=1:6.6p1-2ubuntu1  
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Suggested packages:
  libpam-ssh keychain monkeysphere
The following packages will be DOWNGRADED:
  openssh-client
0 upgraded, 0 newly installed, 1 downgraded, 0 to remove and 17 not upgraded.
Need to get 566 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://jp.archive.ubuntu.com/ubuntu/ trusty/main openssh-client amd64 1:6.6p1-2ubuntu1 [566 kB]
Fetched 566 kB in 0s (751 kB/s)         
dpkg: warning: downgrading openssh-client from 1:6.6p1-2ubuntu2 to 1:6.6p1-2ubuntu1
(Reading database ... 223483 files and directories currently installed.)
Preparing to unpack .../openssh-client_1%3a6.6p1-2ubuntu1_amd64.deb ...
Unpacking openssh-client (1:6.6p1-2ubuntu1) over (1:6.6p1-2ubuntu2) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up openssh-client (1:6.6p1-2ubuntu1) ...

dig

specify name server

➜  ~  dig google.co.jp @ns3.google.com.

; <<>> DiG 9.8.3-P1 <<>> google.co.jp @ns3.google.com.
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 61025
;; flags: qr aa rd; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 0
;; WARNING: recursion requested but not available

;; QUESTION SECTION:
;google.co.jp.          IN  A

;; ANSWER SECTION:
google.co.jp.       300 IN  A   173.194.126.159
google.co.jp.       300 IN  A   173.194.126.152
google.co.jp.       300 IN  A   173.194.126.143
google.co.jp.       300 IN  A   173.194.126.151

;; Query time: 88 msec
;; SERVER: 216.239.36.10#53(216.239.36.10)
;; WHEN: Sun Nov  1 19:52:44 2015
;; MSG SIZE  rcvd: 94

tcpdump

Capture specific host's traffic except for ssh.

tcpdump -n host X.X.X.X and port not 22
  • w: specify packet capture filename
  • i: specify target interface name

strace

sudo strace -p 17480
  • p: attach specific process to show system calls
5
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
3