chown user path
– Change owner of file or directorychown user:group
– Change owner and group of file or directorychown -R user dir
– Change owner of directory and contents (recursively)- chgrp
cat file
– Display the contents of filemore file
– Display file one page at a time; press spacebar to proceed to the next pageless file
– less is similar to more, but also allows moving backwardshead -20 file
– Display the first 20 lines of filetail -f file
– Display the contents of file as it grows – This is especially usefull for following log files.- vi, vim, nano, pico, emacs
which command
– give the full path to commandfind dir -type f -name 'foo*'
– find all files in dir whose name starts with “foo” (note the single quotes, otherwise shell globing would occur)find . -type f -exec grep -l "foo" {} \;
– find all files in the current directory containing “foo”locate file
– find filediff -u file1 file2
– view the differences between two filesdiff -ur dir1 dir2
– view the differences between two directories
File System and Partitioning
- mount, umount
- lsblk, blockdev, fdisk, fsck, mkfs, resize2fs
Text and Stream Processing
strings file
– print all human readable strings in a binary filegrep pattern file
– find all lines in file that contain or match pattern- dd
- pv, tee
- sed, awk, tr, cut, join, column, iconv
wc -l file
– count number of line in file- nl, od, sort, uniq, fold, tac
- csplit, split
- xargs
File Compression
tar zcvf archive.tar.gz files...
– create a gzip-compressed archivetar zxvf archive.tar.gz
– decompress and extract archived files to current directorygzip file.txt
– compresses a file (creates file.txt.gz) and removes the original, uncompressed versiongunzip file.txt.gz
– uncompresses a file that was compressed withgzip
orcompress
and removes the compressed versionzip -r archive.zip files...
– create a zip archiveunzip archive.zip [-d destination_folder]
– extract/decompress zip achiveunzip -l archive.zip
– list the contents of archive.zip- zcat, zless, zmore, zgrep, zdiff – these ‘Z’ commands operate
on gzip-compressed files and provide a ‘Z’ equivalent to their regular
counterparts
zcat system.log.0.gz
– view a compressed filezcat
is identical togunzip -c
zless system.log.0.gz
– ‘Z’ equivalent of less to view a compressed file
Getting Help
man command
– Show the manual for commandhelp command
– Use help for builtin commands- If you do not know if a command is a shell builtin or not, run
type command
.
- If you do not know if a command is a shell builtin or not, run
info command
– for GNU/Linux commands, info often provides a more detailed documentation than the man pageapropos subject
– Search manual pages for subjectman -k
is equivalent to the apropos command
whatis command
– Display one-line manual page descriptions- use
help -d
for a one-line description of a shell builtin
- use
which command
– Show the full path of a commandwhereis command
– locate the binary, source, and manual page files for a command
Process Management
ps aux
– list all processes on the system- top, pstree
- kill, pkill, killall
- disown, nohup
- lsof, fuser
Managing System Services
- service, systemctl
- init, shutdown
User Management
- usermod, useradd, adduser, userdel, passwd
- groupmod, groupadd, gpasswd
whoami
– Show who you are logged in as- id, getent, groups
- who, w, last
Network Commands
ifconfig
– List IP addresses and configuration of network interfaces- ifdown, ifup
dhclient -r eth0
– release current DHCP leasedhclient -v eth0
– obtain IP address from DHCP- ip, route
- iptables
- wpa_supplicant
iwlist
– display information about wireless networks- wpa_cli
- brctl, hostapd
- wget, curl
- ftp
scp -P 5010 foo.txt user@adams204xx.hofstra.edu:/home/user/
– copy local file to linux home directoryscp -P 5010 user@adams204xx.hofstra.edu:/home/user/foo.txt foo.txt
– copy remote file to local system- sftp, tftp, rsync
- ping, nmap, traceroute, arp, tcpdump
nslookup domain
– Perform DNS lookup of domaindig domain
– Perform DNS lookup of domainssh user@host
– Connect to host as userssh-keygen -t rsa -b 4096
– Generate a new SSH key-pairssh-copy-id user@host
– Copy your local key (usually ~/.ssh/id_rsa.pub by default) to the account for user on host to enable key-based (passwordless) authentication into the remote host
System Information
uname -a
– Show kernel information- dmidecode
- lscpu, lspci, lsusb
- hostname
- date, uptime
free
– Show memory and swap usage
Printing
- lp, lpr
Environment
- env, chroot
Shell builtins
- cd, pwd
- clear
- exit
- history, fc
- type
from https://cs.hofstra.edu/docs/pages/reference/commands.html
related post: https://briteming.blogspot.com/2019/06/linux.html
No comments:
Post a Comment