Hello, techies!
Welcome to my article on Linux basic commands. In this article, I will give you some basic bash commands that will help you to interact with Linux efficiently and easily manage bash operations. Here are the few commands that are most frequently used in Linux:
1. PWD (Present Working Directory)
pwd commands tell the location of the current working directory
2. CD (Change Directory)
cd command is used to change the directory
Syntax | Description |
cd directory_path | change to directory path |
cd .. | move back to parent directory |
cd ~ | switch to user home directory |
cd - | change to previous path |
cd . | current location |
3. Date Command
date command in Linux is very important, here is some basic usage of the date command.
Syntax | Description |
date -u | universal date and time |
date +"%T" | display only time |
date +"%B" | display month name full |
date +"%d" | current date |
date +"%D" | half date fomat |
date +"%F" | full date format |
date +"%m%d%H%M%Y%S" | to see the new format |
For more date options refer to doc
4. Calendar Command
cal is a calendar command in Linux to view the calendar of a specific year or month. Here are a few usages in Linux.
Syntax | Description |
cal | current month/year calendar |
cal -y 2020 | show all month of that year |
cal 03 2020 | shows the month of specified number year |
5. Time Command
time is a command in Linux to view resource usage to file timestamp
Syntax | Description |
time | check the execution time |
time [options] | option specific output |
For time options refer to doc
6. Directory Commands
The most used directory commands are mkdir and rmdir
Syntax | Description |
mkdir directory_name | to create a directory |
mkdir -p | specify full parent directory path creation |
mkdir -v | print a message for each created directory |
mkdir -Z | selinux context |
mkdir -m | set the mode on directory |
Sources doc mkdir
Syntax | Description |
rmdir | to remove a empty directory |
Sources doc rmdir
7. List Command
ls is the most used command in Linux with multiple options, here are a few which are used most occasionally
Syntax | Description |
ls -l | long listing |
ls -a | to list hidden files and folder |
ls -i | to list inode of files or folder |
ls -r | to list in reverse order (ascending order) |
ls -t | to list according to time |
ls -h | to list in human-readable format |
ls -lS | to list in desc order of file size |
ls -d | to list directory |
ls -hl | to list in human-readable format |
Note: We can use the combination of options together also
Sources doc
8. Move Command
mv is the command in Linux used to rename a file/folder
mv [options] old_name new_name
For options refer to doc
9. Touch Command
touch is the command in Linux used to create an empty file.
touch [options] file_name
For options refer to doc
10. Vi Command
vi is the inbuilt file editor command in Linux with multiple options, at the basic level just know the syntax and for options refer to doc
vi [options] file_name
Option used for editing, deleting, saving files within vi editor
- Press esc + : i = to enter in insert mode
- Press esc + : q = to quit file without modifying
- Press esc + : x = to save file and exit
- Press esc + : w = save the changes made in file
- Press esc + : q! = exit file discarding the changes made in file
- Press esc + : yy = to yank line (copy line)
- Press esc + : dd = to delete line
Thank you for reading!
Source link