Skip to content
phuonglab edited this page Jan 3, 2022 · 13 revisions

Linux utils

1. ======= useful command ==========

  • fzf is a general-purpose command-line fuzzy finder

  • find all files containing specific text

    • Basic

      grep -rnw '/path/to/somewhere/' -e 'pattern'
    • This will only search through those files which have .c or .h extensions:

      grep --include=\*.{c,h} -rnw '/path/to/somewhere/' -e "pattern"
    • This will exclude searching all the files ending with .o extension:

      grep --exclude=\*.o -rnw '/path/to/somewhere/' -e "pattern"
    • For directories it’s possible to exclude one or more directories using the --exclude-dir parameter. For example, this will exclude the dirs dir1/, dir2/ and all of them matching *.dst/:

      grep --exclude-dir={dir1,dir2,*.dst} -rnw '/path/to/somewhere/' -e "pattern"
  • find and replace text by cmd

    perl -i -p -e 's{home/osboxes/vwtm_ut/}{"new sting"}g' ~/MicroSAR.patch

2. ======= git ==========

$ git clean -fd
git clean -f
git apply --whitespace=nowarn  ~/br_lge_extensions.patch
git reset --hard HEAD
git clone --recursive

3. Remote develop

  • Use ssh without password

    $ssh-keygen -t rsa
    $ssh-copy-id -i ~/.ssh/id_rsa.pub {user}@{host}
  • Download a single file from a remote ftp server to your machine:

    $sftp {user}@{host}:{remoteFileName} {localFileName}
  • Upload a single file from your machine to a remote ftp server:

    $sftp {user}@{host}:{remote_dir} <<< $'put {local_file_path}'
  • ssh and drobear for embedded target

    • cross compile drobear

    • copy dropbear dropbearkey

    • use dropbearkey to generate key

    • run drobear

4. Utility tools

4.1. Check Disk Space with NCurses Disk Usage

4.2. Simple terminal UI for git commands

Clone this wiki locally