- ls - used to list files
- date - to show current date
- cal - calendar
- -a and other type of syntax in commands are called wild cards.
- init 0 sutdown
- init 1 single user mode
- init 2 multiple user mode with no network
- init 3 multiple user mode under CLI
- init 4 User definable
- init 5 multiple user mode with GUI
- init 6 reboot the system
- To check IP info:
- ip add
- ifconfig
- ping - to see if other server is active
- man - shows the manual of any command
- whoami - shows the user
- which - finds the path
- e.g, which ftp
- whereis - detailed patch
- pwd - shows the current directory.
- ls displays three permissions.
- r = read
- w = write
- x = execute
- and d means directory.
- if ls shows - instead of d then its file.
- ls / shows all file present
- rwx/-wx/r-x
- the first part is user, second part is group, third part is others.
- - means no permission
- ls in detail:
- ls -a shows hidden files
- ls -lS - sorts according to file size
- ls -d*/ to list all directories
- ls *.txt - to show specific extensions
- whatis - shows information of any command in single line
- tracert - does routing
- cd - to change the directory.
- ls *.* - list files only with extensions
- mkdir - create directory
- mkdir -p - to create folder within a folder
- e.g, mkdir -p a/b/c
- mkdir names/{austin,John} - creates two folders, austin and John.
- history - shows all the commands used on server by user line by line
- ! - runs the old command by writing the number found from history command
- e.g, !2
- cat - used to display text file, copy, append
- cat > file.txt
- > used to create a file and in insert mode.
- CTRL + C to save.
- To append just use >>
- cat > abc.txt > stdin > standard input
- cat abc.txt > stdout > standard output
- cat file.txt abc.txt > out.txt - combines two file into new one
- head - view top 10 line
- head -n 5 file.txt - shows first five top lines
- tail - to view last 10 lines
- cat -b - show lines that are not empty
- cat -E shows $ at end, means end of line.
- less file.txt - to open a file, search, etc.
- Write / to search for file
- less +/test file.txt - Directly search test in file .txt
- Press g in less to go up
- press G in less to go to end the of file.
- cp source path destination path
- to copy
- mv - to rename file
- mv oldfile.txt newfile.txt
- mv - also used to move files.
- grep - used for pattern matching
- grep "great" file.txt
- grep -i - ignore case sensitive
- grep -o - only print the matched parts of a matching line
- grep -n - print with line number
- wc - word count
- wc -l - show word count
- grep -i -o "is" file.txt | wc -l - shows the amount of is word in the file
- grep "great" file.txt | wc -l - shows the amount of great word in the file
- -l - number of line
- ps -u username - shows all the process of the user
- rm -i filename.txt - remove file and -i means interactive
- rm -r - to remove files/folders recursively, means deleting everything such as files in different sub folder.
- -f - to skip asking.
- find - check if file exists
- e.g, find /root/sandbox/test -name *.txt - to find all files with .txt extension
- CPU Info: lscpu
- OS Version: cat /etc/os-release
- df - shows the disk that is free
- df -h - to show disk free in human readable form
- du - to show the disk used
- du -sh - to show file size only
- free - to show the RAM
- rmdir - only remove directory that are empty
- rmdir -pv - remove directory even if its not empty
- v - verbose
- p - parent
- However, it will not remove the folder if the file is present.
- nano - a text editor
- chmod is used to set the file permission
- + to add permission
- - to remove permission
- chmod o-x file.txt
- take execute permission from others
- u - user
- g - group
- o - others
- r - read
- w - write
- x - execute
- chmod ugo = rw
- all three gets read and write permission
- chmod ugo-rw file.txt remove all permissions from all
Recent Pastes