Skip to content

Instantly share code, notes, and snippets.

@anyboo
Last active June 24, 2018 07:42
Show Gist options
  • Save anyboo/43adc7ec003c125de5e1337a53d25c43 to your computer and use it in GitHub Desktop.
Save anyboo/43adc7ec003c125de5e1337a53d25c43 to your computer and use it in GitHub Desktop.

Unix Command Manual

collect unix common command for macOS

netstat -a | grep ssh
pkg-config --list-all
source ~/.bash_profile
sudo tail -f /var/log/system.log
:w !sudo tee %
:w !sudo tee > /dev/null %
tty
ssh -v ## check ssh agent configuration
  • configuration tool for certain machine settings in System Preferences
sudo systemsetup -setremotelogin on
sudo systemsetup -setremotelogin off
sudo systemsetup -getremotelogin

arbitrary TCP and UDP connections and listens listen port 22 then received message and display

sudo nc -l 22

connect 127.0.0.1 port 22 then send message

nc 127.0.0.1 22

Specifies that nc should just scan for listening daemons, without sending any data to them

nc -z host.example.com 20-30

netstat -an | grep 22

- need comments

sudo lsof -i -P | grep 22 launchd 1 root 96u IPv6 0x0d940bb0 0t0 TCP *:22 (LISTEN) launchd 1 root 99u IPv4 0x10b46abc 0t0 TCP *:22 (LISTEN)

eval ssh-agent Agent pid 9700


**manipulates a domain**

launchctl list | grep ssh launchctl list com.openssh.ssh-agent


locale locale: Cannot set LC_CTYPE to default locale: No such file or directory locale: Cannot set LC_ALL to default locale: No such file or directory LANG=POSIX LC_CTYPE=zh_CN.UTF-8 LC_NUMERIC="POSIX" LC_TIME="POSIX" LC_COLLATE="POSIX"


visit [ibrahimlawal's solved](https://gist.github.com/ibrahimlawal/bfec7092cb64d46d8f9d1fd2c0c3d9c8)
[Running MacOS X without a GUI](http://bill.welliver.org/space/start/2017-05/running_macos_x_without_a_gui?PSESSIONID=db4b8ec9316fc49c989b)

- AT tasks

at atq at -c job

>/usr/lib/cron/jobs/

atrun

Execute the following command as root to enable atrun:

launchctl load -w /System/Library/LaunchDaemons/com.apple.atrun.plist

> com.apple.atrun.plist
 /var/at/jobs      Directory containing job files
 /var/at/spool     Directory containing output spool files
/var/at/lockfile  Job-creation lock file.

- check route table

netstat -rn

>Routing tables
>
>Internet:
Destination        Gateway            Flags        Refs      Use   Netif Expire
default            192.168.2.1        UGSc          215        0     en0
127                127.0.0.1          UCS             0       11     lo0
127.0.0.1          127.0.0.1          UH            191 12775916     lo0
169.254            link#5             UCS             0        0     en0
192.168.2          link#5             UCS             1        0     en0
192.168.2.1/32     link#5             UCS             1        0     en0
192.168.2.1        e8:fc:af:a2:40:70  UHLWIir         6       77     en0   1190
192.168.2.123/32   link#5             UCS             0        0     en0
192.168.2.255      ff:ff:ff:ff:ff:ff  UHLWbI          0        7     en0
224.0.0/4          link#5             UmCS            1        0     en0
224.0.0.251        1:0:5e:0:0:fb      UHmLWI          0        0     en0
255.255.255.255/32 link#5             UCS             0        0     en0

```route -n get default```
>   route to: default
destination: default
       mask: default
    gateway: 192.168.2.1
  interface: en0
      flags: <UP,GATEWAY,DONE,STATIC,PRCLONING>
 recvpipe  sendpipe  ssthresh  rtt,msec    rttvar  hopcount      mtu     expire
       0         0         0         0         0         0      1500         0 
       
  #### configuring your network in terminal ####
- Turning Wi-Fi on or off

networksetup -getairportpower networksetup -setairportpower

- Setting the AirPort network

networksetup -getairportnetwork networksetup -setairportnetwork [password]

- Managing preferred wireless networks

networksetup -listpreferredwirelessnetworks networksetup -addpreferredwirelessnetworkatindex [password] networksetup -removepreferredwirelessnetwork networksetup -removeallpreferredwirelessnetworks <device name

- Additional options

/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport airport -c airport -I airport -S


**change terminal title**
```echo -n -e "\033]0;YOUR TITLE HERE\007"```

### How do I solve the problem that the terminal display "Failed to set locale, defaulting to C warning " ###
To set i18n stuff CentOS/Fedora and RedHat Enterprise Linux call a special script called /etc/profile.d/lang.sh. Make sure this file exist in your system:
```$ ls -l /etc/profile.d/lang.sh```

If file exist just call it:
```$ source /etc/profile.d/lang.sh```

Verify that LANG and LC_* shell variable are set:

$ echo "$LANG" $ echo "$LC_CTYPE"


### CentOS start command & enable service on boot ###

systemctl start nginx systemctl enable nginx


### Check Linux OS Information by terminal ###
```shell
cat /etc/*-release
lsb_release -a
uname -a

Find Out My Linux Distribution Name and Version

@anyboo
Copy link
Author

anyboo commented Mar 17, 2018

locale

locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=POSIX
LC_CTYPE=zh_CN.UTF-8
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"

visit ibrahimlawal's solved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment