0% found this document useful (0 votes)
63 views4 pages

Here Is A List of Basic Linux Commands

Here are the key commands for navigating and managing files and directories in Linux according to the document: 1. The pwd command displays the current working directory. The cd command changes directories. 2. The ls command lists files and directories. Options like -a show hidden files and -l provides more details. 3. Commands like cp, mv, mkdir, rmdir and rm allow copying, moving, creating, and removing files and directories. 4. Other commands search for files (locate, find), view disk usage (df), manage permissions (chmod), and process management (top, kill).

Uploaded by

logasarangam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views4 pages

Here Is A List of Basic Linux Commands

Here are the key commands for navigating and managing files and directories in Linux according to the document: 1. The pwd command displays the current working directory. The cd command changes directories. 2. The ls command lists files and directories. Options like -a show hidden files and -l provides more details. 3. Commands like cp, mv, mkdir, rmdir and rm allow copying, moving, creating, and removing files and directories. 4. Other commands search for files (locate, find), view disk usage (df), manage permissions (chmod), and process management (top, kill).

Uploaded by

logasarangam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Here is a list of basic Linux commands

1. pwd command
Use the pwd command to find out the path of the current working directory (folder) you’re
in. The command will return an absolute (full) path, which is basically a path of all the
directories that starts with a forward slash (/). An example of an absolute path is
/home/username.

2. cd command
type cd followed by the directory’s absolute path: cd
/home/username/Movies.
There are some shortcuts to help you navigate quickly:

cd .. (with two dots) to move one directory up


cd to go straight to the home folder
cd- (with a hyphen) to move to your previous directory

3. ls command
enter ls /home/username/Documents to view the content of Documents.
There are variations you can use with the ls command:

ls -R will list all the files in the sub-directories as well


ls -a will show the hidden files
ls -al will list the files and directories with detailed information like the permissions, size,
owner, etc.

4. cat command

Here are other ways to use the cat command:

cat > filename creates a new file


cat filename1 filename2>filename3 joins two files (1 and 2) and stores the output of them
in a new file (3)
to convert a file to upper or lower case use, cat filename | tr a-z A-Z >output.txt
5. cp command, mv command
6. mkdir command
There are extra mkdir commands as well:

To generate a new directory inside another directory, use this Linux basic command mkdir
Music/Newfile
use the p (parents) option to create a directory in between two existing directories. For
example, mkdir -p Music/2020/Newfile will create the new “2020” file.
7. rmdir command

If you need to delete a directory, use the rmdir command. However, rmdir only allows
you to delete empty directories.
8. rm command

The rm command is used to delete directories and the contents within them. If you only
want to delete the directory — as an alternative to rmdir — use rm -r.
9. touch command
Enter touch /home/username/Documents/Web.html to create an HTML file entitled Web
under the Documents directory.
10. locate command
You can use this command to locate a file, just like the search command in Windows. What’s
more, using the -i argument along with this command will make it case-insensitive, so you
can search for a file even if you don’t remember its exact name.
use an asterisk (*). For example, locate -i school*note command will search for any file that
contains the word “school” and “note”, whether it is uppercase or lowercase.
11. find command
As an example, find /home/ -name notes.txt command will search for a file called notes.txt
within the home directory and its subdirectories.

Other variations when using the find are:

To find files in the current directory use, find . -name notes.txt


To look for directories use, / -type d -name notes. Txt
$ whereis <application name>
$ which <application name>

12. grep command


To illustrate, grep blue notepad.txt will search for the word blue in the notepad file. Lines
that contain the searched word will be displayed fully.
13. df command
Use df command to get a report on the system’s disk space usage, shown in
percentage and KBs. If you want to see the report in megabytes, type df -m.
14. chmod command
15. kill command:-
ps –a , ps ux

There is a total of sixty-four signals that you can use, but people usually only use two
signals: SIGTERM (15) — requests a program to stop running and gives it
some time to save all of its progress. If you don’t specify the signal when entering
the kill command, this signal will be used. SIGKILL (9) — forces programs to stop
immediately. Unsaved progress will be lost.

16. top command


As a terminal equivalent to Task Manager in Windows, the top command will display a list of
running processes and how much CPU each process uses.
17. echo command
This command is used to move some data into a file. For example, if you want to add the
text, “Hello, my name is John” into a file called name.txt, you would type echo Hello, my
name is John >> name.txt
18. hostname command
-a, --alias alias names
-A, --all-fqdns all long host names (FQDNs)
-b, --boot set default hostname if none available
-d, --domain DNS domain name
-f, --fqdn, --long long host name (FQDN)
-F, --file read host name or NIS domain name from given file
-i, --ip-address addresses for the host name
-I, --all-ip-addresses all addresses for the host
-s, --short short host name
-y, --yp, --nis NIS/YP domain name

19. useradd, userdel command


useradd is used to create a new user, while passwd is adding a password to that user’s account. To
add a new person named John type, useradd John and then to add his password type, passwd
123456789.
To remove a user is very similar to adding a new user. To delete the users account type, userdel
<UserName>.

20. Using netstat -tulpn shows that Apache already uses port 80 on this machine.

21. To disable the repo packages go to -->

/usr/share/application/software-settings click the iCON

Just untick the box it disable the repo packages.

22. To view the installe s/w logs.

Var/cache/yum/ --repo subpackages


logfile=/var/log/yum.log -- S/W logs

23. To add the user has sudoers user

Step1. Add the user and set the password

Step2 Verify the Wheel Group is Enabled – etc/sudoers edit remove the # commend in

## Allows people in group wheel to run all commands

# %wheel ALL=(ALL) ALL


Then save and exit the file
type the CMD usermod –aG <group name> <user name>

su – UserName
Check the root folder

sudo ls -la /root

24. To list out all running services

# systemctl --type=service --state=active

Then stop or disable the service

# sudo systemctl stop tomcat.service


# sudo systemctl disable tomcat.service

25. Memory info

You can grab the same info from /proc/meminfo file using the following cat

$ cat /proc/meminfo

Meminfo

# free
# free [options] # free -m
# free -k
# free -t
# free -l
# free -o
# free -s 2
# free -g

-b,-k,-m,-g show output in bytes, KB, MB, or GB


-l show detailed low and high memory statistics
-o use old format (no -/+buffers/cache line)
-t display total for RAM + swap
-s update every [delay] seconds
-c update [count] times
-V display version information and exit

You might also like