Home Basic Linux Shortcuts and Commands
Post
Cancel

Basic Linux Shortcuts and Commands

Use the following in a Linux Terminal

Example

1
root@linux1:~$ whoami

Connection

SSH

The syntax to use SSH is very simple. We only need to provide two things:

  1. The IP address of the remote machine
  2. Correct credentials to a valid account to login with on the remote machine
1
ssh username@MACHINE_IP

Users

CommandDescriptionSyntax
whoamiConfirm Current Userwhoami
suSwitch Current Usersu username

Directories

Directory Navigation

CommandDescriptionSyntax
cdChange directory to named directorycd /dir1/dir2
cd ..Go up a directorycd ..
cd /Go to home directorycd /
cd /var/logAccess system logscd /var/log
findSearch for files and directories in a specified location or directory hierarchyBelow

find - Search for files and directories in a specified location or directory hierarchy

1
find -name filename.txt

Directory Contents

CommandDescriptionSyntax
pwdPrint the current working directorypwd
lsList files and directories in the current directoryls
ls –helpList the possible options that the command acceptsls –help
man lsProvide the manual for lsman ls
ls -aList all files and directories, including hidden onesls -a
ls -lhList files and directories in long format with readable file sizesls -lh
clearclear all terminal textclear
catDisplay the contents of a filecat filename
grepSearch for a pattern in a fileBelow

grep - Search for a pattern in a file

1
grep "String to lookup" filename.extension

Directory Commands

CommandDescriptionSyntax
touchCreate filetouch filename
mkdirCreate a foldermkdir directoryname
cpCopy a file or foldercp filename filename2
mvMove a file or foldermv filename2 filename3
rmremoverm filename
fileDetermine the type of a filefile filename

Permissions

CommandDescriptionSyntax
ls -lhList files with permissionsls -lh

Learn more about Linux permissions.

Terminal Text Editors

CommandDescriptionSyntax
nanocreate (new filename) or edit (filename) a file using nanonano filename
VIMcreate (new filename) or edit (filename) a file using VIMVIM filename

Viewing Processes

CommandDescriptionSyntax
psProvide a list of the running processes as our user’s sessionps
ps auxSee system processes and other user tasksps aux
topReal-time statistics system processesps aux
killKill a command with associated PIDkill 0123
This post is licensed under CC BY 4.0 by the author.