Basic linux Commands For Beginners

Basic Linux Commands For Beginnners

Directory Commands

Commands Operation
mkdir abc
Create directory named abc
mkdir -p abc
Create directory if it does not exist
mkdir -p abc/xy­z/123 
Create all direct­ories and subdir­ect­ories if they do not exist
Show the current directory
cd abc
Change to directory abc
cd ..
Change to the parent directory
cd ../xyz
Change to the sibling directory xyz
cd -
Change back to previous directory
List files in directory
ls -la
List files, including dot-files, with extra info
ls -lhSr
List files in reverse size order; w/friendly size


File Operations

Commands Operation
touch file
update file last modified date; create file if not exists
cat file
output contents of file
less file
paged output contents of file
cp file1 file2
copy file1 to file2
mv file1 file2
mv file1 to file2
rm file
delete file
head -5 file
show the first 5 lines of file
tail -5 file
show the last 5 lines of file
tail -f file
show the last few lines of the file and follow output


Shell Shortcuts

Commands Operation
Stop the current command
Go to start of line
Go to end of line
Search command history
Clear the screen
Run last command
Run last command that starts with abc


Simple Regular Expres­sions

Commands Operation
match any character once
match the preceding character 0 or more times
match the preceding character 1 or more times
match the preceding character 0 or 1 time
group patterns
match the pattern on the left OR right
match the start of the line
match the end of the line


Shell Variables

Commands Operation
Show all enviro­nment variables
echo $ABC
Show a specific enviro­nment variables
Create a local variable
export ABC=123
Create a variable accessible by child processes
Used node.js code; expects value to be production or anything else
Home directory

2 thoughts on “Basic linux Commands For Beginners”

Leave a Comment