Category:Linux Commands

From ElectroDragon Wiki
Revision as of 22:00, 31 January 2020 by Chao (talk | contribs) (→‎Tools)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Commands

use Ctrl + O to save file use Ctrol + X to quit

More info can see on this page.

Common

  • Vi: type i to edit, type esc to exit edit mode, type :x to save editing
  • screen
Name Type available in description
neo4j Example Example
Napkin Example Example
JRuby Example Example
Java coding Example
ssh network Example
git coding Example
lsof Example Example
libc6-armel Example Example
Bash common Example
Busybox Example Example
cpulimit system Example
Transmission network openwrt
Shadowsocks network openwrt
mjpeg streamer video Example
Linux Motion video Example
Nano editor Example
opkg system Example
perl coding Example
vsftpd network Example
wget network Example
yaaw network Example
Htop system Example monitor system status
Psensor system Example monitor CPU status
apache2 internet Example apache internet server
nginx internet Example widely used internet server, maybe better than apache2
Php5 internet Example lanuage
mysql internet Example database
  • matchbox-keyboard florence sudo
  • apt-get install gdebi
  • sudo apt-get install synaptic

rSync file

Basic syntax of rsync command - rsync options source destination Sufffix

Header text Header text Header text
Example -v verbose
Example -r copies data recursively (but don’t preserve timestamps and permission while transferring data
Example -a archive mode, archive mode allows copying files recursively and it also preserves symbolic links, file permissions, user & group ownerships and timestamps
Example -z compress file data
Example -h human-readable, output numbers in a human-readable format
Example -z compress during transfer
Example -H, --hard-links keep the hard links
Example -S, --sparse sparse file special treatment to save DST space

Examples

Type Header text Header text
Basic
  • rsync -avSH /home/coremail/ /cmbak/
  • rsync -azv /var/opt/installation/inventory/ /root/temp/
copy local file from /home/coremail to /cmbak
Example Example Example
Example Example Example

Open windows software

  • install app win: apt-get install wine


Proxy

SS client

  • apt-get install shadowsocks
  • sslocal -c ss.json

Proxy - ProxyChains

  • proxychains > tsocks

Proxy - Polipo

  • Install polipo: apt-get install polipo
  • config /etc/polipo/config
proxyAddress = "0.0.0.0"
socksParentProxy = "127.0.0.1:1080"
socksProxyType = socks5
chunkHighMark = 50331648
objectHighMark = 16384
serverMaxSlots = 64
serverSlots = 16
serverSlots1 = 32
  • restart it: /etc/init.d/polipo restart
  • restart and try:
export http_proxy="http://127.0.0.1:8123/"
curl www.google.com
  • proxychains: /etc/proxychains.conf
  • tsocks: sudo nano /etc/tsocks.conf

Find IP in LAN:

  • install nmap: sudo apt-get install nmap
  • nmap -sn 192.168.1.0/24

or use netdiscover

  • sudo apt-get install netdiscover
  • sudo netdiscover -r 192.168.1.0/24 -i wlan0
  • change wlan0 to eth0

Send udp data to a IP

  • sendip -p ipv4 -is 192.168.1.81 -p udp -us 5070 -ud 5060 -d "Hello" -v 192.168.1.81
  • Refer to ESP Light

Media

  • media play with omxplayer, command: omxplayer example.mp3
  • to force output : omxplayer -o hdmi example.mp3
  • or: omxplayer -o local example.mp3
  • Use lxmuisc or VLC: apt-get install lxmusic
  • Omx GUI player TBOplayer


Use Minidlna

sudo apt-get install minidlna
  • edit connf for minidlna /etc/minidlna.conf
port=8200
media_dir=/media/
friendly_name=dlna

restart it

sudo /etc/init.d/minidlna force-reload

opkg package management

  • list-installed
  • remove
  • update
Openwrt opkg configuration.png

Commands

Category Command Description example example description


File/Folder cd change directory
  • cd ..
  • cd /
  • cd .
-
File/Folder cat print file content to screen - -
File/Folder touch change file to current system time, or create new file - -
File/Folder mkdir make directory mkdir -m 700 electrodragon -m for mode 700
File/Folder tailf diplay the last 10 lines of the file tailf /srv/www/logs/www*access.log -
File/Folder pwd list current folder pwd -
File/Folder cp copy file cp -r folder /home/
File/Folder rm -rf remove the file or folder, r=? f=force -
File/Folder
  • ls -l
  • ls -a
list the user and group -a include all files ls -l
  • drwxrwxr-x 1 root root 8192 Nov 10 03:18 SSK
  • 3th root = user, 4th root =group, SSK folder name
  • -a show all files and folders
  • -l show in long mode
  • -R Recursively
File/Folder mv move or rename files and folders mv /usr/lib/* /zone

File/Folder Right

Basic

root@www:~/sh# ls -al
total 32
drwxr-xr-x  4 root root 4096 Dec 13 06:26 .
drwx------ 10 root root 4096 Dec 13 05:56 ..
-rwxr-xr-x  1 root root 1226 Dec 13 05:48 backup.sh
drwxr-xr-x  3 root root 4096 Dec 13 05:42 bk
drwxr-xr-x  8 root root 4096 Dec 13 06:04 .git
-rwxr-xr-x  1 root root  561 Dec 13 06:03 loadmonitor.sh
-rwxr-xr-x  1 root root    0 Dec 13 06:26 mem.sh
-rwxr-xr-x  1 root root  778 Dec 13 06:00 nginx_log.sh
-rwxr-xr-x  1 root root  280 Dec 13 05:48 uptime.sh

For line drwxr-xr-x 3 root root 4096 Dec 13 05:42 bk

  • d is directory, rwx is write/read/run right, 1st group for owner, 2 for group, 3 other users
Category Command Description example example description


File/Folder Right chown change folder owner and group
  • chown -R oracle:oinstall /home/pi
  • chown root:debian-transmission SSK
  • oracle is user, oinstall is group
  • set user root and group debian-transmissoin for folder SSK
File/Folder Right chmod change folder/file permission chmod -R 700 /opt/oracle 700 is the permission, R means folder and files, recursive
File/Folder Right usermod -a -G Add the user to the supplementary group(s). Use only with the -G option. usermod -a -G pi debian-transmission add debian* to pi group
File/Folder Right Usermod -G add user to a group usermod -G root pi add user pi to root group
File/Folder Right
  • id
  • whoami
  • groups: groups <user>
  • passwd
  • su switch user
  • sudo get root right
  • check user in which group
  • groups root
  • root : root indiecity debian-transmission
File/Folder Right chgrp change group
  • chgrp debian-transmission /mnt/usbel/Torrents/mytrasnmission/incomplete
  • chgrp debian-transmission /mnt/usbel/Torrents/mytrasnmission/complete
change folder group

User and Group

  • userdel username

Net

Category Command Description example example description
User right groupadd or groupdel add/del new group groupadd group1 -
User right alias
  • set alias name for command
  • add alias on boot: ~/.bashrc for single user
  • or /etc/bashrc or /etc/bash.bashrc for all user (ubuntu, lubuntu)
  • reboot to make it work.
alias p="pwd" or p='pwd'
Net ping ping ip address ping 192.168.0.1
Net ifconfig show network info ifconfig
Net wget download a file from internet


System

Category Command Description example example description
System-package apt-get install, remove, update, remove --purage package apt-get install install package
System-package sudo dpkg -i debfile install *.deb package


System su switch user su
System lsusb, lsmod list usb, modules - -
System dmesg Boot info - -
System crontab -e run programme periodically
  • 0 0 * * * rm -rf /tmp/motion/*.* # rm all the files in motion folder at 0:0
  • 0 */2 * * * /sbin/service httpd restart # restart httpd every two hours
-
System help help command - -
System man show manual man update-rc.d -
System ps -x show current process - -
System top system status - -
System hostname show/edit hostname hostname moon change hostname to "moon", also need to change /etc/hosts
System ps show process
  • ps -A | grep ssh*
  • ps -ef | grep mosquitto
check if service ssh on or off
System free -m
  • check free memory
  • #total: Total memory size;
  • #used: memory has been used;
  • #free: free memory;
  • #shared: shared memory size;
  • #buffers: used for buffer memory;
  • #cached: used for cache memory
- -

Screen

  • Screen, sync SSH to Serial of RPI -> Install first sudo apt-get install screen -> screen /dev/ttyAMA0/ 115200

Tools

  • FileZilla
  • WinScp
  • SecureCRT
  • Xshell

Packages

Nano

Install

ubuntu@ubuntu:~/c_enviroment/sample$ sudo apt-get install nano

A simple tutorial on how to use nano is: http://www.howtogeek.com/howto/42980/the-beginners-guide-to-nano-the-linux-command-line-text-editor/

One thing you may notice with this sketch, it compiles to the command line. This example shows how you can pass parameters to the sketch when calling it from the command line. This is optional as you will see in some of the other sketches, but does add some benefit to writing sketches to run on the pcDuino.

Pages in category "Linux Commands"

The following 3 pages are in this category, out of 3 total.