• Cheatsheet - Linux, Yocto & Git
    • FitImage
      • GPIO handling at i.MX8M Mini
        • PHYTEC VM
          • RAM Configuration at PHYTEC i.MX8M Mini
            • Setup qbee Device Management on phyBOARD-Polis
              • Start video at boottime
                • Using phyLinux to build a yocto BSP with a build-container
                  • Using thingsboard.io to connect phyBOARD-Polis to the Cloud

                    Cheatsheet - Linux, Yocto & Git

                    01 22, 2026 10:49

                    This article shows the commands that can be helpful for development.

                    Linux Commands

                    Files & Directories

                    Command

                    Description

                    ls

                    list all regular files in directory

                    ls -l

                    list with more information

                    ls -a

                    list all files (including .* files)

                    mkdir dir

                    create a directory

                    cd dir

                    change to directory

                    cd ..

                    parent directory

                    cd -

                    previous directory

                    cd 

                    home directory

                    pwd

                    show current directory

                    ./dir

                    dir relative to current dir

                    cp A/file   B/file

                    copy file to B

                    cp file ~/

                    copy file to home dir

                    cp dir/file .

                    copy file in dir to current dir

                    cp -r dir newdir

                    copy dir recursively

                    spc file user@serveradress:/path-to-directory

                    secure copy file from A to location B

                    spc user@serveradress:/path-to-file .

                    secure copy file from B to location A

                    mv A/file B/file

                    move file from to B

                    mv oldname newname

                    rename a file

                    ln -s original linked

                    create symbolic link to file or dir

                    rm file

                    remove file (no undo!)

                    rm -rf dir

                    remove dir and contents (no undo!)

                    *

                    all regular files

                    .*

                    all hidden files & directories

                    *.ext

                    all files with extension ext

                    Redirection, Displaying Files & Searching

                    Command

                    Description

                    command > file
                    redirect command output to file
                    command  >> file

                    append command output to file

                    command1 | command2
                    redirect command1 output to command2
                    cat file
                    display file
                    less file
                    display file by pages
                    head file
                    display first 10 lines of file
                    tail file

                    display last 10 lines of file

                    tail -f file
                    display last 10 lines of file with continuous updates
                    grep string file
                    search for string within file
                    grep -r string dir
                    search for string in files in dir
                    find . -name "file"
                    find file recursivly from current dir
                    locate file
                    quick search using index for file

                    Changing File Permissions

                    file/dir permissions are defined as: user|group|other = rwx|rwx|rwx

                    r--
                    read1004
                    -w-
                    write0102
                    --x
                    execute0011

                    change file/dir permissions by category (user, group, other or all(=ugo))

                    CommandDesrciption
                    chmod u+rw file
                    add read & write permissions to user
                    chmod a-x file
                    remove execute permission from all user
                    chmod 644 file
                    set file as readable by all, writable by owner
                    chmod 755 file

                    set file as readable/executable by all, writable by owner

                    chmod -R XYZ dir

                    set permission of dir & contents recursively to XYZ

                    Other Useful Commands

                    CommandDescription
                    diff A B
                    compare files and B
                    diff -r A/ B/

                    compare dirs

                    ps -ef
                    show running processes
                    kill -9 PID
                    kill a proces with PID
                    tar czf archive dir
                    create archive from dir
                    wc file
                    size of file in lines/words/bytes
                    df -Th
                    show size, filesystem & usage data for all partitions
                    du -sh dir
                    show size of dir
                    TAB

                    autocomplete

                    history
                    show command history
                    !N
                    execute command from history
                    CTRL-r
                    reverse search history
                    su - user

                    switch to user

                    su -
                    switch to root
                    sudo command
                    execute command as root (configure via /etc/sudoers)
                    ifconfig -a
                    display all network interfaces
                    ping ip.ip.ip.ip
                    test network with another machine
                    uname -r
                    check kernel version
                    dmesg
                    show kernel logs
                    ./program
                    run program from local dir (not on PATH)
                    program &
                    run program in background (release shell)
                    • can select text with mouse
                    • copy selected text to buffer: CTRL-SHIFT-c
                    • paste buffer after cursor: CTRL-SHIFT-v
                    • insert selected text at new location with mouse: click middle mouse button

                    Editing Files with vi

                    CommandDescription
                    vi file
                    open file to edit
                    ESC
                    enter Command Mode
                    i
                    enter Editing Mode
                    :N
                    goto line N
                    :G
                    goto end
                    yy
                    copy current line to buffer
                    p
                    paste buffer after current line
                    x
                    delete current character
                    dd
                    delete current line
                    u
                    undo last change
                    /string

                    find string after cursor

                    ?string
                    find string before cursor
                    n
                    find next occurrence
                    :w
                    save file
                    :wq
                    save file and exit
                    :q!
                    exit without saving

                    Git Commands

                    Getting Started

                    CommandDescription
                    git config --global user.name <USER>

                    git config --global user.email <EMAIL>
                    identity setup
                    mkdir <DIR>; cd <DIR>
                    git init; git add
                    git commit -m <INITIAL MSG>
                    local repository setup
                    git clone
                    remote repository setup
                    git <COMMAND> --help
                    invoke manpage for <COMMAND>

                    Basic Operations

                    CommandDescription
                    git add <FILE>
                    add a tracked file to the index (stage)
                    git reset <FILE>
                    remove a file from the index (unstage)
                    git commit <FILE> -m <Message>
                    commit a staged file to the local repository
                    git status
                    list staged, unstaged and untracked files
                    git diff
                    changed files in working directory but not staged
                    git diff --staged
                    changed files that are staged but not committed
                    git log
                    git log -p 
                    git show <commit ID>

                    show commit IDs with messages

                    also display diff

                    also display diff

                    git format-patch -<N>

                    generate patches for N latest commits

                    Working with Branches

                    CommandDescription

                    git branch

                    git branch -a

                    list branches

                    local branches

                    local and remote branches

                    git checkout -b TEST
                    create local branch "TEST"
                    git checkout origin/TEST -t
                    create a remote-tracking branch "TEST"
                    git checkout TEST
                    switch to a branch "TEST"

                    Renaming & Deleting Files

                    A "git rename" or "git delete" operation needs to be committed to the repository.

                    CommandDescription
                    git mv <OLD FILE> <NEW FILE>
                    rename a file and add the new file to the index
                    git rm <FILE>
                    delete a file and add action to the index
                    git log --stat -M
                    show log messages related to deleted/renamed files

                    Changing History

                    This is intended for local repositories. Log messages can be changed, multiple commits can be "squashed" into a single. Only do this before pushing changes to a remote/shared repository.

                    CommandDesription
                    git commit --amend
                    changing the log message of the last commit
                    git rebase -i

                    selectively change the log message of multiple commits, reorder commits, squash commits, etc. -

                    This opens an editor with different actions that can be performed on each commit

                    git rebase 
                    apply all changes from a topic branch to the HEAD of the main branch

                    Working with Stash

                    The status of the working directory and the index can be stacked into stash. The branch is initially restored to the latest commit. It is later possible to recover stashed work back into a branch.

                    CommandDescription
                    git stash push
                    add current work to the stash
                    git stash list
                    list WIP in the stash
                    git stash pop <stash>
                    recover the saved status of the stash in current branch
                    git stash drop <stash>
                    remove stashed work without applying

                    Managing Commits in Local Branches

                    CommandDescription
                    git merge <branch>
                    git merge --ff <branch>
                    apply all changes from another branch
                    git cherry-pick <commit ID>
                    apply a specific commit to current branch
                    git diff <branch1> <branch2>
                    display differences between branches
                    git revert <commit ID>
                    revert a commit (added to history)

                    Synchronizing a Remote Repository

                    CommandDescription
                    git fetch
                    fetch all remote branches
                    git pull
                    fetch and merge to remote-tracking branches
                    git push
                    push commits from all tracking-branches to the remote repository

                    Local Repository Cleanup

                    CommandDescription
                    git reset
                    reset branch to that of the last commit, do not reset the working directory
                    git reset <commit ID>
                    reset the branch to that of a chosen commit, do not reset the working directory
                    git reset --hard
                    git reset --hard <commit ID>

                    reset a branch's staging area and working directory (losing all non-committed changes!)


                    Yocto Commands

                    Getting Started

                    CommandDescription
                    source poky/oe-init-build-env <build_dir>
                    create build directory (or use existing build directory)
                    vi conf/local.conf
                    MACHINE ?= "<machine>"
                    DL_DIR ?= "${TOPDIR}/downloads"
                    SSTATE_DIR ?= "${TOPDIR}/sstate-cache"
                    EXTRA_IMAGE_EXTRA_INSTALL += "<extra_packages>"
                    modify local configuration

                    Building Recipes & Bitbake

                    CommandDescription
                    bitbake -f <recipe>
                    force a recipe to run
                    bitbake -k <image_recipe>
                    continue as far as possible after an error
                    bitbake <recipe>
                    build a recipe
                    bitbake -c listtasks <recipe>
                    list a recipe's tasks
                    bitbake -e <recipe>
                    list a recipe's environment variables
                    bitbake -c clean <recipe>
                    clean from 'do_unpack' onwards
                    bitbake -c cleansstate <recipe>
                    as above plus remove shared state
                    bitbake -c cleanall <recipe>
                    clean everything including downloads and shared state

                    Creating Layers & Recipes

                    CommandDescription
                    bitbake-layers create-layer <layer>
                    create new layer
                    bitbake-layers add-layer <layer>
                    add new or upstream layer to build directory
                    bitbake-layers remove-layer <layer>
                    remove layer from build directory

                    Creating a New Recipe

                    CommandDescription
                    recipetool create -o <recipe> <package_location>
                    to create a starting point recipe for a package
                    devtool add  <package_location>
                    to create a starting point recipe for a package and place it in the devtool workspace

                    Recipe Variables

                    VariableDescription
                    ${VAR}
                    value of VAR
                    VAR = "a"
                    set a value
                    VAR ?= "a"
                    set a default value
                    VAR ??= "a"
                    set a weak default value
                    VAR := ${A}
                    immediate evaluation
                    VAR:value
                    variable overrides
                    append *= .=
                    append to a variable
                    prepend =+ =.
                    prepend to a variable
                    remove
                    remove from a variable

                    Special Recipe Variables

                    VariableDescription
                    LICENSE* / LIC_FILES_CHECKSUM*
                    license file and associated checksum (*required)
                    SRC_URI*
                    source package location (*required)
                    WORKDIR
                    work directory
                    S
                    source directory
                    B
                    build directory
                    D
                    destination directory
                    THISDIR
                    recipe directory
                    FILES
                    files and dirs to be included
                    DEPENDS
                    build dependencies
                    RDEPENDS
                    runtime dependencies
                    RRECOMMENDS
                    useful extra packages
                    RCONFLICTS
                    packages conflicted with
                    RREPLACES
                    packages replaced by
                    EXTRA_OECONF
                    autotools configure
                    EXTRA_OEMAKE
                    autotools compile options
                    EXTRA_OECMAKE
                    cmake options
                    BPN
                    base package name
                    PN
                    recipe name
                    PV
                    recipe version
                    PR
                    recipe revision

                    Finding Files

                    CommandFile
                    less <build_dir>/conf/local.conf
                    MACHINE ?= "<machine>"
                    DISTRO ?= "<distro>"
                    find . -name "<machine>.conf"
                    ./poky/meta/conf/machine/<machine>.conf
                    find . -name "<distro>.conf"
                    ./poky/meta-poky/conf/distro/<distro>.conf
                    find BSP or Distro configuration
                    <build_dir>/tmp/deploy/images/<machine>/
                    images
                    <build_dir>/tmp/deploy/<package_type>/

                    packages (e.g. rpm)

                    <build_dir>/tmp/deploy/images/sdk/

                    SDK Installers

                    bitbake -e <recipe> | grep ^WORKDIR=

                    recipe work directory

                    bitbake -e <recipe> | grep ^B=

                    recipe build directory

                    bitbake -e <recipe> | grep ^S=

                    recipe source directory

                    bitbake -e <recipe> | grep ^D=

                    recipe destination directory

                    Listing Layers & Recipes

                    CommandDescription
                    bitbake-layers show-layers
                    list active layers
                    bitbake-layers show-recipes
                    list available recipes
                    bitbake-layers show-appends
                    list append recipe
                    bitbake-layers show-overlayered
                    show recipes which exist in more than one layer
                    bitbake-layers show-cross-depends

                    list cross layer dependencies

                    devtool search <recipe>
                    search for recipes in the build system
                    devtool find-recipe <recipe>
                    locate any recipe

                    Devtool

                    CommandDescription
                    devtool build <recipe>
                    build workspace recipe
                    devtool edit-recipe <recipe>
                    edit workspace recipe
                    devtool build-image <image_recipe>
                    build image including workspace recipes
                    devtool update-recipe <recipe>
                    update workspace recipe after source changes
                    devtool finish <recipe> <layer>
                    add source changes to existing recipe
                    devtool finish <recipe> <new_layer>
                    add source changes to append recipe

                    Copyright 2022 by Doulos Ltd. All rights reserved.