0% found this document useful (0 votes)
11 views

Linux Commands

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Linux Commands

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Linux commands

1. ls command
The ls command lists the content of a folder, including files and directories.
Here’s the syntax:
ls [options] [directory_or_path]

2. pwd command
To check the full path of your current working directory, use the pwd command.
Its syntax is as follows:
pwd [options]

3. cd command
Use cd to navigate between directories in your Linux VPS. It doesn’t have any
option, and the syntax is simple:
cd [path_or_directory]

4. mkdir command
The mkdir command lets you create one or multiple directories. The syntax
looks like this:
mkdir [options] directory_name1 directory_name2

5. rmdir command
Run rmdir to delete empty directories in your Linux system. The command
syntax looks like this:
rmdir [options] directory_name
6. rm command
The rm command deletes files from a directory. You must have the write
permission for the folder or use sudo. Here’s the syntax:
rm [options] file1 file2

7. cp command
Use the cp command to copy files from your current directory to another folder.
The syntax looks like this:
cp file1 file2 [target_path]

8. mv command
The main usage of the mv command is to move a file or folder to another
location. Here’s the syntax:
mv file_or_directory [target_directory]

9. touch command
Run the touch command to create a new empty file in a specific directory. The
syntax is as follows:
touch [options] [path_and_file_name]

10. file command


The file command checks a file type, such as TXT, PDF, or other. The syntax is as
follows:
file [file_name]

11. zip and unzip commands


The zip command compresses one or multiple files into a ZIP archive, reducing
their size. Here’s the syntax:
zip [options] zip_file_name file1 file2
12. tar command
The tar command bundles multiple files or directories into an archive without
compression. The syntax looks as follows:
tar [options] tar_file_name file1 file2

13. nano, vi, and jed command


nano, vi, and jed commands let you edit files. They have the same syntax, except
at the beginning, where you specify the name of the tool:
nano/vi/jed file_name

14. cat command


The concatenate or cat command has various usages. The most basic one is
printing the content of a file. Here’s the syntax:
cat file_name

15. grep command


Global regular expression print or grep lets you search specific lines from a
file using keywords. It is useful for filtering large data like logs. The syntax looks
as follows:
grep [options] keyword [file]

16. sed command


Use the sed command to search and replace patterns in files quickly. The basic
syntax looks like this:
sed [options] 'subcommand/new_pattern/target_pattern' input_file
17. head command
Use the head command to print the first few entries of a file. The basic syntax is
as follows:
head [options] file_name

18. tail command


The tail command is the opposite of head, allowing you to print the last few
lines from files or another utility’s output. Here are the syntaxes:
tail [options] file_name

19. awk command


The awk command searches and manipulates regular expression patterns in a
file. Here’s the basic syntax:
awk '/regex pattern/{action}' input_file.txt

20. sort command


Use the sort command to rearrange a file’s content in a specific order. Its syntax
looks as follows:
sort [options] [file_name]

21. cut command


The cut command selects specific sections from a file and prints them as a
Terminal output. The syntax looks like this:
cut options file

22. diff command


The diff command compares two files and prints their differences. Here’s the
syntax:
diff file_name1 file_name2
23. tee command
The tee command outputs another command’s results to both the Terminal and
a file. It’s helpful if you want to use the data for further processing or backups.
Here’s the syntax:
command | tee [options] file_name

24. locate command


The locate command searches for a file and prints its location path. Here’s the
syntax:
locate [options] [keyword]

25. find command


The find command searches for a file within a specific directory. Here’s the
syntax:
find [path] [options] expression

26. sudo command


superuser do or sudo enables non-root users who are part of the sudo
group to execute administrative commands. Simply add it at the beginning of
another utility like so:
sudo [options] your_command

27. su and whoami commands


The su command lets you switch to another user in the Terminal session. The
syntax looks as follows:
su [options] [username]
28. chmod command
Chmod lets you change the permissions of files or directories. The basic
syntax looks as follows:
chmod [options] [permission] [file_or_directory]

29. chown command


The chown command lets you change the ownership of files, directories, or
symbolic links. Here’s the syntax:
chown [options] newowner:newgroup file1 file2

30. useradd, passwd, and userdel command


Use the useradd command to create a new account in your Linux system. The
syntax is as follows:
useradd [options] new_username

31. df command
The df command checks your Linux system’s disk usage, displaying the used
space in percentage and kilobyte (KB). The syntax looks like this:
df [options] [file system]

32. du command
To check the size of a directory and its content, use the du command. Here’s the
syntax:
du [directory]

33. top command


The top command displays all running processes in your system and their
hardware consumption. The syntax looks like this:
top [options]
34. htop command
Like top, the htop command lets you display and manage processes in your
Linux server. It also shares the same syntax:
htop [options]

35. ps command
The ps command summarizes the status of all running processes in your Linux
system at a specific time. Unlike top and htop, it doesn’t update the information
automatically. Here’s the syntax:
ps [options]

36. uname command


The unix name or uname command displays detailed information about your
Linux machine, including hardware, name, and operating system kernel. Its
basic syntax looks as follows:
uname [options]

37. hostname command


Use the hostname command to check your VPS hostname and other related
information. Here is the syntax:
hostname [options]

38. time command


The time command measures the execution time of commands or scripts to gain
insights into your system performance. The basic syntax looks as follows:
time command_or_script
39. systemctl command
The systemctl command is used to manage services in your Linux system. Here’s
the basic syntax:
systemctl subcommand [service_name][options]

40. watch command


The watch command lets you continuously run a utility at a specific interval to
monitor changes in the output. Here’s the basic syntax:
watch [options] command_name

41. jobs command


Jobs are tasks or commands that are running in your current shell. To check
them, use the jobs command with the following syntax:
jobs [options] [Job_ID]

42. kill command


Use the kill command to terminate a process using its ID. Here’s the basic
syntax:
kill [signal_option] Process_ID

43. shutdown command


The shutdown command lets you turn off or restart your Linux system at a
specific time. Here’s the syntax:
shutdown [option] [time] [message]
44. ping command
The ping command sends packets to a target server and fetches the responses. It
is helpful for network diagnostics. The basic syntax looks like the following:
ping [option] [hostname_or_IP_address]

45. wget command


The wget command lets you download files from the internet via HTTP, HTTPS,
or FTP protocols. Here’s the syntax:
wget [options] [URL]

46. cURL command


Use the cURL command to transfer data from or to a server by specifying its
URL. The basic syntax looks as follows:
curl [options] URL

47. scp command


The scp command lets you securely copy files and directories between systems
over a network. The syntax looks as follows:
scp [option] [source username@IP]:/[directory and file name] [destination
username@IP]:/[destination directory]

48. rsync command


The rsync command syncs files or folders between two destinations to ensure
they have the same content. The syntax looks as follows:
rsync [options] source destination
49. ip command
The ip utility lets you list and manage your system’s network parameters,
similar to the ifconfig command in older Linux distros. Here’s the syntax:
ip [options] object command

50. netstat command


The netstat command displays information about your system’s network
configuration. The syntax is simple:
netstat [options]

51. traceroute command


The traceroute command tracks a packet’s path when traveling between hosts,
providing information like the transfer time and involved routers. Here’s the
syntax:
traceroute [options] destination

52. nslookup command


The nslookup command requests a domain name system (DNS) server to
check a domain linked to an IP address or vice versa. Here’s the syntax:
nslookup [options] domain-or-ip [dns-server]

53. dig command


The domain information groper or dig command displays information about a
domain. It is similar to nslookup but more comprehensive. The syntax looks as
follows:
dig [options] [server] [type] name-or-ip
54. history command
Run the history command to check previously run utilities. Here’s its syntax:
history [options]

55. man command


The man or manual command displays a comprehensive guide of another
utility. The syntax looks like the following:
man [options] [section_number] command_name

56. echo command


Use echo to print text in your command as a Terminal output. Here’s the syntax:
echo [options] [text]

57. ln command
The ln command links files or directories with a shortcut. The syntax looks as
follows:
ln [options] source target

58. alias and unalias command


The alias command lets you set another name for a string that belongs to a file,
text, program, or command name. Here’s the syntax:
alias name='string'

59. cal command


The cal command displays a calendar in your Linux command-line interface.
Here’s the syntax:
cal [options] [month] [year]

60. apt and dnf command


The apt command lets you manage advanced package tool (APT) libraries in
Debian-based operating systems such as Ubuntu and Kali Linux. The syntax
looks like this:
apt [options] subcommand

You might also like