Skip to content

Latest commit

 

History

History
92 lines (66 loc) · 3.65 KB

LFCE_EssentialCommands.md

File metadata and controls

92 lines (66 loc) · 3.65 KB

LFCE Essential Commands - 5%

  1. Use version control tools
  2. Manipulate file content programmatically
  3. Run commands on many systems simultaneously
  4. Install Linux Distribution

Use version control tools

  • Following some common git commands:

    git config --global user.name Ivan Grozni
    git config --global user.email something.gmail.com
    git config --list
    git init --bare /dir/bashscripts
    git status
    git add -A
    git commit -a -m "Initial Commit"
    git push origin master
    git status
    git checkout -b latest
    git branch
    git add delme
    git commit -a -m 'add new file'
    git checkout master
    git merge test
    git branch -d test
    git pull origin
    git log
    git show
    git diff master latest
    git log -S "<String to search for>" -> Shows what commit changed that line.

    git clone ssh://[email protected]/tmp/test ./opala/ -> Clone repo from remote machine using ssh.

    • Had to set git config receive.denyCurrentBranch ignore from the repo side and change group and user owner != root.

Manipulate file content programmatically

  • Use the following command to do it: sed, uniq, grep, tr, cut

    cut --complement -d " " -f2,3 original > new -> Delete 2nd and 3 column from file.

    cat file | sort | uniq -d -> Show only duplicate lines.

    uniq -u -> Shows only unique lines.

    awk -F: '$3 > 100' -> Show all lines which have number greater than 100 into the 3th column.

    sort -t: -k 3 -n -r -> Sort by the 3th column separated by ":" by numerical order in descending fashion. - More on sort: https://www.educba.com/sort-command-in-unix/

    Check them into the LFCS repo.

Run commands on many systems simultaneously

  • If you are managing multiple Linux servers, and you want to run multiple commands on all the Linux servers in parallel fear not. To achieve, this you can use the pssh (parallel ssh) program, a command line utility for executing ssh in parallel on a number of hosts.

  • How to install it: yum install pssh

  • How to use it:

    • Create a file with random name pssh-hosts containig the IPs of the host you want to connect to with the following syntax:

      # cat pssh-hosts
      192.168.0.101:22
    • Start using it:

      pssh -h pssh-hosts -i -o dir_name -l root -A df -h

      -h: used to specify host file

      -i: used to display standard output and standard error

      -o: to save standard output to a given directory

      -l: to include a default username on all hosts that do not define a specific user

      -A: to ask for a password and send to ssh

Install Linux Distribution

  • If you are studying for LFCE you need to know this already!

Check everything from LFCS essentials

Back to top of the page: ⬆️