Basic operations with Kali Linux(PART1)

bob218
4 min readAug 16, 2023

--

of bob218

What is Linux? Everything You Need to Know (2023) (softwarelab.org)

1- sudo is one of the most common Linux commands and allows tasks to be performed that require administrative or root permissions.

When using sudo, the system will ask users to authenticate with a password. Then, the Linux system will record a timestamp as a tracker.
Also, if an attempt is made to run sudo in the Linux command line without authenticating, the system will log the activity as a security event.

sudo apt-get update

2-Use the pwd command to find the path to the current working directory. Simply entering pwd will return the complete current path .

pwd
/home/username

It has two acceptable options:

L or –logical > prints environment variable content, including symbolic links.
P or –physical > prints the actual path of the current directory.

3-To navigate between Linux files and directories, use the cd command.

Running this command without an option will take you to the Start directory. Please note that only users with sudo privileges can execute it.

Suppose you are in /home/username/Documents and want to go to Photos, a subdirectory of Documents. To do this, enter the following command:

cd Photos

If you want to go to a completely new directory, e.g. /home/username/Movies, you must enter cd followed by the absolute path to the directory:

cd /home/username/Movies

cd [username] > goes to another user’s home directory.
cd .. > moves one directory up.
cd- > moves to your previous directory.

4-The ls command lists files and directories within a system. Running it without a flag or parameter will show the current working directory’s content.

To see other directories’ content, type ls followed by the desired path. For example, to view files in the Documents folder, enter:

ls /home/username/Documents

Here are some options you can use with the ls command:

ls -R > lists all the files in the subdirectories.
ls -a > shows hidden files in addition to the visible ones.
ls -lh > shows the file sizes in easily readable formats, such as MB, GB, and TB.

5-Concatenate, or cat, is one of the most frequently used Linux commands. It lists, combines, and writes file content to the standard output. To run the cat command, type cat followed by the file name and its extension. For instance:

cat filename.txt

Here are other ways to use the cat command:

cat > filename.txt creates a new file.
cat filename1.txt filename2.txt > filename3.txt merges filename1.txt and filename2.txt and stores the output in filename3.txt.
tac filename.txt displays content in reverse order.

6-The primary use of the mv command is to move and rename files and directories. Simply type mv followed by the filename and the destination directory. For example, you want to move filename.txt to the /home/username/Documents directory:

mv filename.txt /home/username/Documents

You can also use the mv command to rename a file:

mv old_filename.txt new_filename.txt

7- Use the mkdir command to create one or multiple directories at once and set permissions for each of them. The user executing this command must have the privilege to make a new folder in the parent directory, or they may receive a permission denied error.

mkdir [option] directory_name

For example, you want to create a directory called Music:

mkdir Music

To make a new directory called Songs inside Music, use this command:

mkdir Music/Songs

The mkdir command accepts many options, such as:

  • -m > sets the file permissions. For instance, to create a directory with full read, write, and execute permissions for all users…
mkdir -m777 directory_name
  • -v > prints a message for each created directory.

8- To permanently delete an empty directory, use the rmdir command. Remember that the user running this command should have sudo privileges in the parent directory.

For example, you want to remove an empty subdirectory named school23 and its main folder mydir:

rmdir -p mydir/school23

9-The rm command is used to delete files within a directory. Make sure that the user performing this command has write permissions.

Remember the directory’s location as this will remove the file(s) and you can’t undo it.

rm filename

To remove multiple files, enter the following command:

rm filename1 filename2 filename3

Here are some acceptable options you can add:

i > prompts system confirmation before deleting a file.
-f > allows the system to remove without a confirmation.
-r > deletes files and directories recursively.

10-The touch command allows you to create an empty file or generate and modify a timestamp in the Linux command line.

For example, enter the following command to create an HTML file named Web in the Documents directory:

touch /home/username/Documents/Web.html

PS: I hope this content was useful and thank you for reading:)

💻 Follow me
👏 Give the article 50 claps
📚
Read more articles on Medium
🔗 Connect on social media
Github | Kaggle

--

--

bob218
bob218

No responses yet