GithubHelp home page GithubHelp logo

bash-tutorial's Introduction

Bash-Tutorial

A cheat sheet for bash

Simple traversal

pwd : prints working directory

ls : lists contents of current directory

ls -l : list contents of current directory with extra details

ls -a : list hidden files too

ls /home/user/*.txt : lists all files ending with .txt inside /home/user

cd or cd ~ : change directory to your home directory

cd folder1/folder2/ : change directory to folder2 inside folder1

mkdir mydir : create a new directory named mydir

rmdir mydir : remove directory mydir

touch myfile : create or update a myfile

cp myfile myfile2 : copy myfile into myfile2

cp -r mydir mydir2 : copy mydir into mydir2 (creates new directory if it doesn't exist)

rm myfile : removes myfile

rm -rf mydir : removes mydir and all its contents

mv myfile mydir/ : moves myfile into mydir

mv myfile newfile : renames myfile to newfile

mv mydir newdir : renames mydir to newdir

cat file : outputs the contents of file

cat > file : places standard input into file (^c to end)

head file : output first 10 lines of file

tail file : output last 10 lines of file

tail -f file : output contents of file as it grows (^c to exit)

nano : opens a terminal editor

nano newfile : opens newfile for editing

echo text : prints text on the screen

Output Redirection

cmd > file : redirects stdout to file

echo "text" >> file : appends "text" to file

cmd 2> file : redirects stderr to file

cmd 2>&1 file : redirects stderr and stdout to both terminal and file

Process Management

ps : Display your currently active processes

top : display all running processes

htop : more interactive and colorful version of top

kill pid : kill process with id pid

killall proc : kill all processes named proc*

System info

date : show the current date and time

cal : show this month's calendar

uptime : show current uptime

uname -a : show all kernel information

cat /proc/cpuinfo : show cpu information

cat /proc/meminfo : show memory information

df : show disk usage

du : show directory space usage

free : show memory and swap usage

whereis app : show possible location of app

which app : show which app will be run by default

Help

man command : shows manual for command

command --help or command -h : (almost always) shows short help about the command

Network

ping host : ping host and output results

whois domain : get whois information for domain

dig domain : get DNS information for domain

dig -x host : reverse lookup host

wget file : download file

wget -c file : continue a stopped download

Installation

Install from repository

Ubuntu/Debian based systems

sudo apt-get update or sudo apt update: updates repository list

sudo apt-get upgrade or sudo apt upgrade : installs possible updates

sudo apt-get install package or sudo apt install package : installs package

apt search package or aptitude search package : searches for the package

Fedora

yum update : updates repository list

yum search package : searches for package

sudo yum install package : installs package

Install from file

sudo dpkg -i package.deb : install package from deb file (Debian)

sudo rpm -Uvh package.rm : install package from rpm file (Fedora)

Install from source

./configure

make

make install

May require sudo. Read the README for the source before proceeding.

Resources

Awesome bash

Linux Journey

bash-tutorial's People

Contributors

subhrajitprusty avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.