Introduction To Kali LInux command Line 2
Linux Man Pages
To learn more about a command and its option and arguments and its documentation can be viewed using man commandroot@kali:~# man ls
LS(1) User Commands LS(1)
NAME
ls - list directory contents
SYNOPSIS
ls [OPTION]... [FILE]...
DESCRIPTION
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort is speci‐
fied.
Mandatory arguments to long options are mandatory for short options
too.
-a, --all
do not ignore entries starting with .
-A, --almost-all
do not list implied . and ..
--authorThe man page gives useful information about ls command including its usage, description.
From the above example we can see that
ls -a command it list every directory,files including hidden file.Adding Users in Linux
By default kali offers only the privileged root account.Though many security tools require root privileges to run, you may want to add another unprivileged account for everyday use to reduce the potential for damage to your system. Remember,the root account can do anything on Linux,including removing the root file systems.To add new user to your kali linux system we can use
addusercommandroot@kali:~# adduser teja
Adding user `teja' ...
Adding new group `teja' (1000) ...
Adding new user `teja' (1000) with group `teja' ...
Creating home directory `/home/teja' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for teja
Enter the new value, or press ENTER for the default
Full Name []: teja
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] yAdding a User to sudo group
root@kali:~# adduser teja sudo
Adding user `teja' to group `sudo' ...
Adding user teja to group sudo
Done.
Switching Users
To switch from root user to normal user usesu command
root@kali:~# su teja
teja@kali:/root$ su
Password:
root@kali:~#sucommand switches the user from root to teja.Then to again switch from tejatype su we need to provide the password for root to switch back
To create a new directory
root@kali:~# mkdir newdirectory
root@kali:~# ls
newdirectoryTo create a new file
use touch command
root@kali:~# touch file
root@kali:~#ls
fileCopy command
syntax for copy is cp source destination
root@kali:~# cp file newdirectoryMoving command
syntax for move is mv source destinationroot@kali:~# mv file newdirectoryRemove command
To remove a file use rm commandroot@kali:~# rm fileTo remove a directory you cannot use same command
root@kali:~# rm -r newdirectory/Adding Text to a File
we useecho command to echo a text to terminalroot@kali:~#echo hello world
hello worldInstead of printing the text we can write the text to a file
root@kali:~#echo hello world > fileTo see the contents of the file
root@kali:~#cat file
hello worldIf we echo another text to the file
root@kali:~#echo hello world again >file
root@kali:~#cat file
hello world againThe previous contents of the file are erased and new content overwrites the file.
To Append the File
root@kali:~#echo hai world >> file
root@kali:~#cat file
hello world again
hai worldFile Permissions
If you see the output of ls -l fileroot@kali:~#ls -l file
-rw-r--r-- 1 root root file
-rw-r--r-- says about the file permissions.Linux files have permission to read(r), write (w) and execute (x) and three sets of user permission, three sets of group permission and three sets for all users
Using Grep
The command grep search for the string which is given as argumentroot@kali:~#cat file
hello world again
hai world
root@kali:~#grep again file
hello world again
Comments
Post a Comment