\
), for example, C:\Users\Documents
. In Linux, the path separator is the forward - slash (/
), such as /home/user/documents
.file.txt
and FILE.TXT
are considered the same. In contrast, the Linux command line is case - sensitive. file.txt
and FILE.TXT
are two different files.Linux uses different shells like Bash (Bourne - Again SHell), which is the most common. Each shell has its own set of features and commands, but Bash is widely used due to its flexibility and extensive command support.
set
command. For example, to set a variable MY_VAR
to value
, you can use set MY_VAR=value
.export
command. For example, export MY_VAR=value
.dir
command.dir
cd
command. For example, to go to the Documents
directory under the current user’s home directory:cd %USERPROFILE%\Documents
ls
command. You can add options like -l
for a long - format listing and -a
to show hidden files.ls -la
cd
command. For example, to go to the documents
directory in the user’s home directory:cd ~/documents
echo
command to redirect output to a file. For example, to create a file named test.txt
with some text:echo This is a test > test.txt
copy
command. For example, to copy test.txt
to backup.txt
:copy test.txt backup.txt
touch
command.touch test.txt
cp
command. For example, to copy test.txt
to backup.txt
:cp test.txt backup.txt
findstr
command to search for text in files. For example, to search for the word “example” in all .txt
files in the current directory:findstr /s /i "example" *.txt
grep
command. For example, to search for the word “example” in all .txt
files in the current directory:grep "example" *.txt
shutdown
command. For example, to shut down the computer immediately:shutdown /s /t 0
shutdown
or poweroff
command. For example, to shut down the system immediately:sudo shutdown -h now
choco install googlechrome
apt
package manager is used. For example, to install the vim
text editor:sudo apt update
sudo apt install vim
ping
command. For example, to ping google.com
:ping google.com
ping
command to check network connectivity.ping google.com
history
command to view a list of all previously executed commands. This helps in reusing and modifying commands quickly.#!/bin/bash
backup_dir="/home/user/backup"
source_dir="/home/user/documents"
cp -r $source_dir $backup_dir
Save the above script as backup.sh
, make it executable using chmod +x backup.sh
, and then run it with ./backup.sh
.
man
command to access them. For example, to read the manual page for the ls
command:man ls
Migrating from Windows CMD to the Linux command line might seem challenging initially, but with an understanding of the fundamental concepts, usage methods, common practices, and best practices, it becomes a manageable and rewarding process. By leveraging the unique features of the Linux command line, users can gain greater control over their systems, automate tasks more efficiently, and become more proficient in system administration.