Start with Linux

Command to pull/run ubuntu:

docker pull ubuntu (or) docker run ubuntu

Command to see running processes/containers :

docker ps

Command to see stopped containers as well

docker ps -a

Command to start container in interactive mode

docker run -it image-name

it enters the shell
/:where we are in the file system (in windows we use \)
#:means we have highest privileges ($ is shown except root user)
Linux is case sensitive

Some basic commands

	echo hello - prints hello
	whoami - shows current user
	echo $0 - shows location of the shell program (/bin/bash)
	history - history of commands
	!2 - run 2 command in the history list
	ctrl + L - clear window
	apt - has a bunch of subcommands (list, search, show, install)

Package Manager for Ubuntu : apt (Advanced Package tool)
	apt list - shows all the packages in the database and install status
	apt install nano - looks for nano in package database, if present, 		  installs it
	apt update - update the package database
	(Before installing always run update)
	apt remove nano - uninstall package

Linux File System

In Linux, everything is a file.

Navigating in file system

	pwd : print working directory
	ls : to see files and directory(blue-dir, white-file)
	ls -1 : to see one item per line
	ls -l : to see complete details (permission, user, date, size)
	ls path : to see file content of a path
	cd path : path can be absolute (starts with root /) or relative to working dir
	cd .. : one level up
	cd ../.. : two level up
	cd ~ : to get into the home directory

Manipulate files and directory

	mkdir test : create directory named test
	mv test docker : rename test to docker
	touch hello.txt : create hello.txt file
	touch file1.txt file2.txt file3.txt : create multiple files
	mv hello.txt hello-docker.txt : rename hello.txt to hello-docker.txt
	mv hello.txt /etc : move hello.txt to etc folder
	rm file1.txt file2.txt : remove multiple files
	rm file* : remove all files that start with file
	rm -r docker : remove the directory recursively

View and edit files

	nano : basic text editor for linux
	nano file1.txt : open file1.txt in file editor
	cat file1.txt : see content of this file (cat is concatenate)
	more file1.txt : to see content of long file page by page (moves only down)
	less file1.txt : to see content of long file moving both up and down
	head -n 5 file1.txt : to see first 5 lines
	tail -n 5 file1.txt : to see last 5 lines

Redirection : change the source of input and output

	cat file1.txt > file2.txt : read content of file1 and write to file2
	cat file1.txt file2.txt : read data from file1 and file2 and write to console	
	cat file1.txt file2.txt > combine.txt
	> (redirection operator) can be used with any command
	echo hello > hello.txt : write hello to hello.txt

	< (redirect the standard input)

26 views0 comments

Recent Posts

See All