ls |
List files in directory; current directory is used if no directory is supplied |
$ ls ~/Desktop |
cd |
Change the current working directory |
$ cd /home/centos/ |
pwd |
Print the current working directory |
$ pwd
/home/centos/ |
cp |
Copy a file |
$ cp orig.txt copy.txt |
mv |
Move or rename a file |
$ mv a.txt
Desktop/b.txt |
rm |
Delete a file |
$ rm file.txt |
mkdir |
Create a directory |
$ mkdir examples/ |
rmdir |
Delete a directory (must be empty) |
$ rmdir examples/ |
cat |
Print one or more files to STDOUT |
$ cat file.txt |
grep |
Search for text within a file or STDIN |
$ grep 10.10.1.1
/var/log/apache/* |
file |
Identify the file type |
$ file image.jpg
image.jpg: JPEG Image Data |
head |
Display the first 10 lines of a file (use “-n X” to display first X lines) |
$ head /etc/passwd
$ head -n 5 /etc/passwd |
tail |
Display the last 10 lines of a file (use “-n x” to display first X lines) |
$ rm file.txt |
tail -F |
Display new data as it is appended to the end of a file (useful for watching logs) |
$ tail -F
/var/log/messages |
less |
Display text from STDIN or a file one screen at a time |
$ less /etc/passwd
$ cat file | less |
ps |
Display a list of running processes |
$ ps aux |
lsof |
Display a list of open files |
$ lsof |
netstat |
Display TCP & UDP connection info |
$ netstat -na |
ifconfig |
Display information about your network interfaces, such as your IP address |
$ ifconfig |
su |
Temporarily switch to a different user. Root is used if no username is specified |
$ su – [username] |
sort |
Sort the contents of a file or STDIN |
$ sort /etc/passwd |
uniq |
Remove duplicate lines from a sorted file or sorted STDIN |
$ uniq mylist.txt |
chmod |
Change the permissions (mode) of a file or directory |
$ chmod +w file.txt |
stat |
View detailed information about a file |
$ stat file.txt |
ping |
Send ICMP ECHO_REQUEST to a network host to test connectivity |
$ ping 10.1.1.1 |
whoami |
Display the current username |
$ whoami |
passwd |
Change a user’s password, or your own if no username is specified |
$ passwd [username] |
kill |
Terminate or send a signal to a running process by process ID(PID) |
$ kill 8573 |
ln |
Create a hard or symbolic link to a file |
$ ln [file] [link] |
Leave a Reply