UNIX

UNIX timestamp

Liknande

  • GNU
  • XNU

  • BSD

  • DOS
Bill Joy Brian Kernighan Dennis Ritchie Ken Thompson

Kända personer

  • Bill Joy
  • Brian Kernighan
  • Dennis Ritchie
  • Ken Thompson

Förkortningar

  • UNICS - Uniplexed Information and Computing Service

  • POSIX - Portable Operating System Interface for uniX

  • NPM - Node package manager
  • CRT - Cathode ray tube
  • MC - Midnight Commander

  • csh - C shell
  • ksh - Korn shell
  • sh - Bourne shell

  • SED - stream editor
  • AWK - Aho, Weinberger, and Kernighan
  • RC - runcom

  • SIP - System Integrity Protection

  • MOTD - Message of the day

Lista

cat /etc/shells

Filändelser

  • .sh

Citat

Write failed: Broken pipe You have mail.

Snabbkommandon för UNIX

Visa alla snabbkommandon
  • Tab+?Autocompletes from the cursor position.
  • Ctrl+aMoves the cursor to the line start (equivalent to the key Home).
  • Ctrl+bMoves the cursor back one character (equivalent to the key ?).
  • Ctrl+cSends the signal SIGINT to the current task, which aborts and closes it.
  • Ctrl+e(end) moves the cursor to the line end (equivalent to the key End).
  • Ctrl+fMoves the cursor forward one character (equivalent to the key ?).
  • Ctrl+hDeletes the previous character (same as backspace).
  • Ctrl+iEquivalent to the tab key.
  • Ctrl+jEquivalent to the enter key.
  • Ctrl+kClears the line content after the cursor and copies it into the clipboard.
  • Ctrl+lClears the screen content (equivalent to the command clear).
  • Ctrl+n(next) recalls the next command (equivalent to the key ?).
  • Ctrl+p(previous) recalls the prior command (equivalent to the key ?).
  • Ctrl+r(reverse search) recalls the last command including the specified character(s). A second Ctrl+r recalls the next anterior command that corresponds to the search
  • Ctrl+tTranspose the previous two characters.
  • Ctrl+uClears the line content before the cursor and copies it into the clipboard.
  • Ctrl+wClears the word before the cursor and copies it into the clipboard.
  • Ctrl+y(yank) adds the clipboard content from the cursor position.
  • Ctrl+zSends the signal SIGTSTP to the current task, which suspends it. To execute it in background one can enter bg. To bring it back from background or suspension fg ['process name or job id'] (foreground) can be issued.
  • Ctrl+_Incremental undo, separately remembered for each line.
Install script

Variabler med beskrivningar

Visa alla variabler
$0
The filename of the current script.
$n
These variables correspond to the arguments with which a script was invoked. Here n is a positive decimal number corresponding to the position of an argument (the first argument is $1, the second argument is $2, and so on).
$#
The number of arguments supplied to a script.
$*
All the arguments are double quoted. If a script receives two arguments, $* is equivalent to $1 $2.
$@
All the arguments are individually double quoted. If a script receives two arguments, $@ is equivalent to $1 $2.
$?
The exit status of the last command executed.
$$
The process number of the current shell. For shell scripts, this is the process ID under which they are executing.
$!
The process number of the last background command.
export PATH=$PATH:.
Fönster med Lynx

Kommandon (och vissa förkortningar)

Visa alla kommandon
  • afplay
  • apt - Advanced Package Tool
  • bc
  • cal
  • cd
  • chmod [-R]
  • clear
  • cmp
  • cp
  • curl [-o]
  • date
  • diff
  • ditto
  • drush
  • du
  • echo
  • Emacs
  • ftp
  • git
  • help
  • history
  • ifconfig
  • info
  • ls [-a][-l]
  • man
  • mkdir
  • mv
  • mysql
  • nano
  • open
  • pico
  • ping [-c count][-i wait][-t timeout]
  • pwd
  • rm
  • rmdir
  • say [-v voice]
  • scp
  • sleep
  • ssh
  • sudo
  • tail
  • telnet
  • top
  • touch
  • unzip [-d]
  • uptime
  • vim
  • vimtutor
  • wc
  • who
  • who am i
  • whoami

Rättigheter

Visa alla rättigheter
  1. No permissions (---)
  2. Execute only (rare) (--x)
  3. Write only (rare) (-w-)
  4. Write and execute (rare) (-wx)
  5. Read only (r--)
  6. Read and execute (r-x)
  7. Read and write (rw-)
  8. Read, write, and execute (rwx)
Terminal logotyp

Termination Signals

  • SIGTERM
  • SIGINT
  • SIGKILL
  • SIGHUP

Filer

  • .aliases
  • .bash_aliases
  • .bash_history
  • .bash_profile
  • .bashrc
Logotyp för oh my zsh

ASCII art

__ __ ____ / /_ ____ ___ __ __ ____ _____/ /_ / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ / /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / \____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ /____/ Oh My Zsh Discord
Visa alias för git egrep='grep -E --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox}' fgrep='grep -F --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox}' g=git ga='git add' gaa='git add --all' gam='git am' gama='git am --abort' gamc='git am --continue' gams='git am --skip' gamscp='git am --show-current-patch' gap='git apply' gapa='git add --patch' gapt='git apply --3way' gau='git add --update' gav='git add --verbose' gb='git branch' gbD='git branch -D' gba='git branch -a' gbd='git branch -d' gbda='git branch --no-color --merged | command grep -vE "^([+*]|\s*($(git_main_branch)|$(git_develop_branch))\s*$)" | command xargs git branch -d 2>/dev/null' gbl='git blame -b -w' gbnm='git branch --no-merged' gbr='git branch --remote' gbs='git bisect' gbsb='git bisect bad' gbsg='git bisect good' gbsr='git bisect reset' gbss='git bisect start' gc='git commit -v' 'gc!'='git commit -v --amend' gca='git commit -v -a' 'gca!'='git commit -v -a --amend' gcam='git commit -a -m' 'gcan!'='git commit -v -a --no-edit --amend' 'gcans!'='git commit -v -a -s --no-edit --amend' gcas='git commit -a -s' gcasm='git commit -a -s -m' gcb='git checkout -b' gcd='git checkout $(git_develop_branch)' gcf='git config --list' gcl='git clone --recurse-submodules' gclean='git clean -id' gcm='git checkout $(git_main_branch)' gcmsg='git commit -m' 'gcn!'='git commit -v --no-edit --amend' gco='git checkout' gcor='git checkout --recurse-submodules' gcount='git shortlog -sn' gcp='git cherry-pick' gcpa='git cherry-pick --abort' gcpc='git cherry-pick --continue' gcs='git commit -S' gcsm='git commit -s -m' gcss='git commit -S -s' gcssm='git commit -S -s -m' gd='git diff' gdca='git diff --cached' gdct='git describe --tags $(git rev-list --tags --max-count=1)' gdcw='git diff --cached --word-diff' gds='git diff --staged' gdt='git diff-tree --no-commit-id --name-only -r' gdup='git diff @{upstream}' gdw='git diff --word-diff' gf='git fetch' gfa='git fetch --all --prune --jobs=10' gfg='git ls-files | grep' gfo='git fetch origin' gg='git gui citool' gga='git gui citool --amend' ggpull='git pull origin "$(git_current_branch)"' ggpush='git push origin "$(git_current_branch)"' ggsup='git branch --set-upstream-to=origin/$(git_current_branch)' ghh='git help' gignore='git update-index --assume-unchanged' gignored='git ls-files -v | grep "^[[:lower:]]"' git-svn-dcommit-push='git svn dcommit && git push github $(git_main_branch):svntrunk' gk='\gitk --all --branches &!' gke='\gitk --all $(git log -g --pretty=%h) &!' gl='git pull' glg='git log --stat' glgg='git log --graph' glgga='git log --graph --decorate --all' glgm='git log --graph --max-count=10' glgp='git log --stat -p' glo='git log --oneline --decorate' glod='git log --graph --pretty='\''%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset'\' glods='git log --graph --pretty='\''%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset'\'' --date=short' glog='git log --oneline --decorate --graph' gloga='git log --oneline --decorate --graph --all' glol='git log --graph --pretty='\''%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset'\' glola='git log --graph --pretty='\''%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset'\'' --all' glols='git log --graph --pretty='\''%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset'\'' --stat' glp=_git_log_prettily gluc='git pull upstream $(git_current_branch)' glum='git pull upstream $(git_main_branch)' gm='git merge' gma='git merge --abort' gmom='git merge origin/$(git_main_branch)' gmtl='git mergetool --no-prompt' gmtlvim='git mergetool --no-prompt --tool=vimdiff' gmum='git merge upstream/$(git_main_branch)' gp='git push' gpd='git push --dry-run' gpf='git push --force-with-lease' 'gpf!'='git push --force' gpoat='git push origin --all && git push origin --tags' gpr='git pull --rebase' gpristine='git reset --hard && git clean -dffx' gpsup='git push --set-upstream origin $(git_current_branch)' gpu='git push upstream' gpv='git push -v' gr='git remote' gra='git remote add' grb='git rebase' grba='git rebase --abort' grbc='git rebase --continue' grbd='git rebase $(git_develop_branch)' grbi='git rebase -i' grbm='git rebase $(git_main_branch)' grbo='git rebase --onto' grbom='git rebase origin/$(git_main_branch)' grbs='git rebase --skip' grep='grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox}' grev='git revert' grh='git reset' grhh='git reset --hard' grm='git rm' grmc='git rm --cached' grmv='git remote rename' groh='git reset origin/$(git_current_branch) --hard' grrm='git remote remove' grs='git restore' grset='git remote set-url' grss='git restore --source' grst='git restore --staged' grt='cd "$(git rev-parse --show-toplevel || echo .)"' gru='git reset --' grup='git remote update' grv='git remote -v' gsb='git status -sb' gsd='git svn dcommit' gsh='git show' gsi='git submodule init' gsps='git show --pretty=short --show-signature' gsr='git svn rebase' gss='git status -s' gst='git status' gsta='git stash push' gstaa='git stash apply' gstall='git stash --all' gstc='git stash clear' gstd='git stash drop' gstl='git stash list' gstp='git stash pop' gsts='git stash show --text' gsu='git submodule update' gsw='git switch' gswc='git switch -c' gswd='git switch $(git_develop_branch)' gswm='git switch $(git_main_branch)' gtl='gtl(){ git tag --sort=-v:refname -n -l "${1}*" }; noglob gtl' gts='git tag -s' gtv='git tag | sort -V' gunignore='git update-index --no-assume-unchanged' gunwip='git log -n 1 | grep -q -c "\-\-wip\-\-" && git reset HEAD~1' gup='git pull --rebase' gupa='git pull --rebase --autostash' gupav='git pull --rebase --autostash -v' gupom='git pull --rebase origin $(git_main_branch)' gupomi='git pull --rebase=interactive origin $(git_main_branch)' gupv='git pull --rebase -v' gwch='git whatchanged -p --abbrev-commit --pretty=medium' gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign -m "--wip-- [skip ci]"'

Visa version av Oh My Zsh

zsh --version zsh 5.8.1 (x86_64-apple-darwin21.0) Cathode iTerm 2 logotyp

Program

Drush logotyp FTPManager logotyp Git logotyp IRC MySQL logotyp Vim logotyp

Program

Shebang

#!/bin/sh

Funktion

Hello () { echo "Hello World" }

Kommentarer

# En kommentar

Öppna nuvarande mapp

open .

Upplösning för .png

file *

Skapa symlänk

ln -s /Applications/MAMP/htdocs/ htdocs

Byt lösenord

passwd [username] Changing local password for [username] New Password: Retype New Password:

Tid

date +"%H:%M:%S"

Tid i millisekunder

date +%s

Tid för användare

time

Visa vad slutet av en fil innehåller samtidigt som den kan uppdateras (kan användas för att visa nya felmeddelanden)

tail -f fil

Öppna en fil med ett program

open -a Program "fil"

Flytta dolda filer

mv .* ../

Avsluta ett program

killall program

Information om en fil

stat file

Rättigheter för en fil

stat -f '%A' file

Manual

man command

Hjälp

help
Visa all hjälp GNU bash, version 3.2.57(1)-release (arm64-apple-darwin21) These shell commands are defined internally. Type `help' to see this list. Type `help name' to find out more about the function `name'. Use `info bash' to find out more about the shell in general. Use `man -k' or `info' to find out more about commands not in this list. A star (*) next to a name means that the command is disabled. JOB_SPEC [&] (( expression )) . filename [arguments] : [ arg... ] [[ expression ]] alias [-p] [name[=value] ... ] bg [job_spec ...] bind [-lpvsPVS] [-m keymap] [-f fi break [n] builtin [shell-builtin [arg ...]] caller [EXPR] case WORD in [PATTERN [| PATTERN]. cd [-L|-P] [dir] command [-pVv] command [arg ...] compgen [-abcdefgjksuv] [-o option complete [-abcdefgjksuv] [-pr] [-o continue [n] declare [-afFirtx] [-p] [name[=val dirs [-clpv] [+N] [-N] disown [-h] [-ar] [jobspec ...] echo [-neE] [arg ...] enable [-pnds] [-a] [-f filename] eval [arg ...] exec [-cl] [-a name] file [redirec exit [n] export [-nf] [name[=value] ...] or false fc [-e ename] [-nlr] [first] [last fg [job_spec] for NAME [in WORDS ... ;] do COMMA for (( exp1; exp2; exp3 )); do COM function NAME { COMMANDS ; } or NA getopts optstring name [arg] hash [-lr] [-p pathname] [-dt] [na help [-s] [pattern ...] history [-c] [-d offset] [n] or hi if COMMANDS; then COMMANDS; [ elif jobs [-lnprs] [jobspec ...] or job kill [-s sigspec | -n signum | -si let arg [arg ...] local name[=value] ... logout popd [+N | -N] [-n] printf [-v var] format [arguments] pushd [dir | +N | -N] [-n] pwd [-LP] read [-ers] [-u fd] [-t timeout] [ readonly [-af] [name[=value] ...] return [n] select NAME [in WORDS ... ;] do CO set [--abefhkmnptuvxBCHP] [-o opti shift [n] shopt [-pqsu] [-o long-option] opt source filename [arguments] suspend [-f] test [expr] time [-p] PIPELINE times trap [-lp] [arg signal_spec ...] true type [-afptP] name [name ...] typeset [-afFirtx] [-p] name[=valu ulimit [-SHacdfilmnpqstuvx] [limit umask [-p] [-S] [mode] unalias [-a] name [name ...] unset [-f] [-v] [name ...] until COMMANDS; do COMMANDS; done variables - Some variable names an wait [n] while COMMANDS; do COMMANDS; done { COMMANDS ; }

Läs in fil för bash

source ~/.bash_profile . ~/.bash_profile

Version operativsystem

uname -a

Versionsflagga för program

program --version

List all available commands

compgen -c

Hämta fil

wget -O file example.com/file

curl

curl

Flytta filer till server

scp . user@ip:/folder

Hämta filer från server

scp user@ip:/folder .

Sökfilnamn

find . -name filename

Sök efter ett ord

grep "Word" file.txt

Sök efter ett ord i en specifik fil

cat file.txt | grep Word

Only hidden files

ls -d .*

Sök förutom i en mapp

grep -R --exclude-dir=node_modules 'some pattern' /path/to/search

Filer i mappar

ls -l | wc -l ls -lA | wc -l

Dölj en fil eller mapp

chflags hidden /path/to/file-or-folder

Visa en dold fil eller mapp

chflags hidden /path/to/file-or-folder

Visa dolda filer som defaultMac

defaults write com.apple.finder AppleShowAllFiles TRUE

Extrahera .tar.gz

tar -zxvf file.tar.gz

Extrahera .tar

tar -xvf file.tar

Alias

alias

Senaste besökare

last -10

Användare

users

Grupper

groups /etc/group

Rättigheter för mappar

sudo chown -R username:group directory sudo chmod -R XXX directory

Ändra interface för användare

chsh –s /bin/bash user chsh –s /bin/sh user

Töm historik

history -c

Kör föregående kommando

!!

Personliga filer

~/.bash_profile ~/.bashrc ~/.bash_aliases

Ställ in storlek för historik

HISTFILESIZE=1000000000
HISTSIZE=1000000

Alias

alias ll="ls -la"

Felmeddelande

urls=('www.domain.com'); for i in ${urls[@]}; do http_code=$(curl -I -s $i -w %{http_code}); echo $i status: ${http_code:9:3}; done

Checking Free Disk Space

df -h df -k du

Jämför

Filer (side by side)

diff -y

Mappar

diff -arq folder1 folder2

Upplösning för PNG

file *

How can I calculate the size of a directory?

du -s directory_name

Or to get human readable output

du -sh directory_name

The -s option means that it won't list the size for each subdirectory, only the total size.

Telnet

telnet towel.blinkenlights.nl telnet mapscii.me

Exportera databas med MySQL till fil

mysqldump -u användarnamn -plösenord databas > filnamn.sql

Already have a key?

Copy your key to your clipboard with:

cat ~/.ssh/id_rsa.pub | pbcopy

Change Password over SSH

ssh -t user@server-name-here /bin/passwd

Kopiera på Mac

pbcopy

Klistra in på Mac

pbpaste

SerienummerMac

ioreg -c "IOPlatformExpertDevice" | awk -F '"' '/IOPlatformSerialNumber/ {print $4}'

Röst på Mac

say -v ? Word
Visa alla

Namn på röster

  • Agnes
  • Albert
  • Alex
  • Alice
  • Alva
  • Amelie
  • Anna
  • Bad News
  • Bahh
  • Bells
  • Boing
  • Bruce
  • Bubbles
  • Carmit
  • Cellos
  • Damayanti
  • Daniel
  • Deranged
  • Diego
  • Ellen
  • Fiona
  • Fred
  • Good News
  • Hysterical
  • Ioana
  • Joana
  • Junior
  • Kanya
  • Karen
  • Kathy
  • Kyoko
  • Laura
  • Lekha
  • Luciana
  • Mariska
  • Mei-Jia
  • Melina
  • Milena
  • Moira
  • Monica
  • Nora
  • Paulina
  • Pipe Organ
  • Princess
  • Ralph
  • Samantha
  • Sara
  • Satu
  • Sin-ji
  • Tarik
  • Tessa
  • Thomas
  • Ting-Ting
  • Trinoids
  • Veena
  • Vicki
  • Victoria
  • Whisper
  • Xander
  • Yelda
  • Yuna
  • Zarvox
  • Zosia
  • Zuzana

How to Disable System Integrity Protection (rootless) in Mac OS X

Status

csrutil status

Disable

csrutil disable

Enable

csrutil enable

Reboot

reboot

USB

lsusb

Replace with sed

sed -i -e 's/search\/replace/g' file

Default shell for a user

/etc/passwd

Lists all shells installed on the system

cat /etc/shells

Change its default shell

chsh Homebrew (brew.sh)
Visa alla kommandon i brew Example usage: brew search TEXT|/REGEX/ brew info [FORMULA|CASK...] brew install FORMULA|CASK... brew update brew upgrade [FORMULA|CASK...] brew uninstall FORMULA|CASK... brew list [FORMULA|CASK...] Troubleshooting: brew config brew doctor brew install --verbose --debug FORMULA|CASK Contributing: brew create URL [--no-fetch] brew edit [FORMULA|CASK...] Further help: brew commands brew help [COMMAND] man brew https://docs.brew.sh

Visa beroenden för brew

brew list brew deps brew deps --tree brew deps --tree --installed
Haskell logotyp Terminal

Program

Enheter

Linux logotyp Logotyp för GNU - GNU's Not Unix! Logotyp för GPL - General Public License

Liknande

Cosmic adventure

Liknande

Logotyp för ENIX Logotyp för ENIX

Liknande namn

UNIX timestamp med PHP

date('U')

UNIX timestamp med MySQL

UNIX_TIMESTAMP()

UNIX timestamp med Javascript

Date.now() Testa här new Date().getTime() Testa här *nix Logotyp för AT&T - American Telephone and Telegraph

Externa länkar

Shell logotyp

Kuriosa