Sunteți pe pagina 1din 7

2 USING KALI LINUX

Linux Command Line

Linux CLI gives you access to a command processor called Bash that allows you to control the
system by entering text-based instructions.

Root is the superuser in Linux systems, and it has complete control of Kali.

Linux Filesystem

In Linux, everything is a file. All files can be viewed, edited, deleted, created, and moved.

pwd - to see your current directory.

Changing Directories

To change ro your Desktop from anywhere, cd /root/Desktop

Entering cd ../etc from there moves us back up to the root filesystem and then to the /etc
directory.

Learning about Commands: The Man Pages

"man <command>"

User Privileges
Adding a User to the sudoers File

Use the sudo command along with the command that you want to run as a root.

For the newly created user georgia to be able to run privileged commands you need to add her
to the sudoers file, which specifies which users can use the sudo command.

To do so, enter adduser username sudo.

Switching Users and Using sudo

To switch users in your terminal session, say from the root user to georgia, use the su command
as shown below.
To change back to the root user, enter the su command with no username. You will be prompted
for the root's password (toor).

Creating a New File or Directory

To create a new, empty file called myfile, use the touch command.

To create a new directory in your current working directory, enter mkdir directory.

Copying, Moving, and Removing Files

To copy a file, use the cp command.

The syntax is cp <source> <destination>.

To move a file, use the mv command.

mv <source> <destination>

You can remove a file from the filesystem by entering rm <file>. To remove files recursively use
the -r command.

rm -rf >>> forcibly removes the entire filesystem.


Adding text to a File

The echo command echoes what you enter to the terminal.

To save text to a file, you can redirect your input to a file instead of to the terminal with the >
symbol.

To see the contents of your new file you can use the cat command.

Now echo a different line of text into myfile as shown next.

The > overrides the previous contents of the file.

Appending Text to a File

To append text to a file, use >> .

FILE PERMISSIONS

If you look at the long output of ls -l on myfile you can see the current permissions for myfile.
permissions (-rw-r--r--)

number of links to the file (1)

the user and the group that own the file (root root)

the file size (47 bytes)

the last time the file was edited (April 23, 21;15)

the filename (myfile)

read (r) / write (w) / execute (x)

3 sets of user permission: permission for the owner, group, and all users.

To change the permission on a file, use the chmod command.

When entering new file permission, you use one digit for the owner, one for the group, and one
for the world.

E.g. To give the owner full permissions but the group and the world no permission to read, write,
or execute a file, use chmod 700.

EDITING FILES

Two popular editors - vi and nano.

NANO
Searching for Text:

Use ctrl-W and then enter the text to search for at the search prompt as shown.

To exit, press ctrl-X

vi

In vi, you also see the filename, number of lines, and the current cursor position.

To edit a file, enter I to put vi into insert mode.

You should see the word INSERT displayed at the bottom of your terminal.

Once finished, press ESC to exit insert mode and return to command mode.

Once in command mode, you can use commands to edit your text.

E.g. position the cursor at the line we and enter dd to delete the word we from the file.

To exit, enter :wq (write changes and quit).

S-ar putea să vă placă și