顯示具有 linux 標籤的文章。 顯示所有文章
顯示具有 linux 標籤的文章。 顯示所有文章

2020年5月21日 星期四

[Linux & cli] Useful Linux command

Details
The following are some useful commands which usually made use and always being forgotten when needed, here is a note down.
  • Edit /etc/fstab to mount new drives (files system, mount point, type, options, dump, pass)
    • /dev/sdb1   /home/jacky/Documents/2tb-hdd   ext4   defaults  0   0
    • mount -av (run from root, show the mount point)
  • Run command and pipe all output to file
    • do_something 2>&1 | tee -a some_file (2>&1 is to direct all stderr to stdout)
  • Clear all text in a text file
    • > someTxtFile.txt
  • Kill process occupied by a known port (e.g. 32769)
    • sudo kill -9 $(sudo lsof -t -i:32769)
References

2020年3月22日 星期日

Useful bash command sytax (keep updating...)

Below are the useful syntax / tricks of bash commands that are easily forgot but handy. Keep them noted here

General Bash Command

1. Assignment of the value of variable word to parameter if and only if it is null
${parameter:=word}

2. Text processing using AWK example 1
echo $CODEBUILD_BUILD_ID | awk -F":" '{print $2}'

Output and pipe the string of variable CODEBUILD_BUILD_ID to awk as input, use ":" as separator and output the second element of the separated words

3. Cut out a range of characters for further processing
echo abcde | cut -c 1-2

cut accepts standard input and file as the reading source, cut -c 1-2 "xxx"  is not allowed

4. Find row of string existence and replace the whole line
SOME_VER=v1.0 && sed -i "/LINE TO FIND/c\VER=$SOME_VER" ./dir/to/file

Variable "SOME_VER" is defined, and then search for the line contains words "ROW TO FIND" and substitute with VER=v1.0 (variable substituted)

Note: The double quote "", single quote cannot perform variable substitution, single quote does not interpolate anything

"c\SomeText" is to replace the selected line with SomeText

Docker command
1. Close all running containers
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)

2. Show docker entrypoint command without truncate
docker ps --no-trunc --format '{{.Command}}'

2015年1月7日 星期三

[Ubuntu] Installing Symantec Endpoint Protection for Linux (SEPFL)

Although there is only a very few chance for us to install SEP in Ubuntu, but I have chance to do this, so I share my experience here.

Steps
SEPFL does not support 32 bit Ubuntu, therefore you may need to recompile the auto protection module.
  • Decompress the source code from the following directory
    ./yourSEPFLFileDir/src/ap-kernelmodule.tar.bz2
  • Recompile the Symantec Endpoint to support 32 bit Ubuntu
    sudo ./build.sh --kernel-dir /lib/modules/$(uname -r)/build
  • Once success, the auto protection of SEPFL should work as follows
References

2014年12月29日 星期一

[Ubuntu] Recommended package for arp-scan

arp-scan is a good tool to perform arp-scanning which can

  1. Do troubleshooting for IP confliction
  2. IP<>MAC mapping
  3. Get production manufacturer
Just install with: sudo apt-get install arp-scan

Common cmd used:
  • Specify a list of IP addresses as arguments: sudo arp-scan -I eth0 192.168.1.1 192.168.1.2 192.168.1.3
  • Specify network/bits: sudo arp-scan -I eth0 192.168.1.0/24
  • Specify network:netmask: sudo arp-scan -I eth0 192.168.1.0:255.255.255.0
  • Specify address range: sudo arp-scan -I eth0 192.168.1.3-192.168.1.27
  • Read a list of IP addresses from a file: sudo arp-scan -I eth0 --file=ip-address-list.txt