Tuesday, 10 January 2017

Basic Steps For Beginners To Use UNIX/LINUX



Directory Commands
pwd – this is often used check the present working directory.
mkdir dir – Make a directory dir
rmdir dir – remove a directory dir
cd dir – change directory to dir
ls – list files
ls -lt – gives the details of files, directory and links.
cd / – brings you directly to the root folder.
Bash Commands
uname – shows system and kernel information
mount – show mounted file system
date – shows date
cal – displays calendar
whoami – displays logged in username
man command – is the help command, which shows the manual for command typed.
File Operations
touch filename – to create a file.
cat filename – to view and concat the file.
more filename – can add filter on paging of the file.
file filename – get the type of file like a text or ascii
cp file1 file2 – will copy the content from file1 to file2
cp source target – copy the file to specified path.
mv file new_filename – Rename a file.
mv -i source target – gives an interactive prompt of yes or no while moving the files.
rm filename – deletes that file.
head filename – shows first 10 lines of the file.
tail filename – shows last 10 lines of the file.


ls Options
ls -a – shows all files including hidden files.
ls -R – recursive list
ls -r – shows reverse order of files.
ls -t – sorting the files by last modified.
ls -s – sorts files according to filesize.
ls -lt – shows a detailed information about the files and directories.
Searching Options
grep -i – searches for both upper and lower case.
grep -l -list the names of files with matching lines.
grep -c – counts the line that contains the pattern.
grep -v – inverts the search to display lines that do not match the pattern.
find /dir/ -username – finds files owned by that user name in dir
find /dir/ -mmin num – finds files modified less than number of minutes ago in dir
File Permission Numbers
Calculate permissions by adding the values of the permis­sions as mentioned below.
4 – read (r)
2 – write (w)
1 – execute (x)

Source: http://wiki.liway.info
Eg:
Octal Modes
| Permissions
644
rw- r– r–
751
rwx r-x –x
775
rwx rwx r-x
777
rwx rwx rwx


Octal digits for permissions.
Octal Value
| Permission Set
7
r w x
6
r w –
5
r – x
4
r – –
3
– w x
2
– w –
1
– – x
0
– – –
File Permissions
umask – checks for the stored value
chmod 775 filename – changes the accessing mode of the file to 775.
chmod -r filename – retrieves the read permission from filename.
chmod +x filename – grants execute permission to filename.
chmod u+x, go+r filename – grants execute permission to Owner of the file, and grants read permission to Group and Others.
Process Management
ps – shows the snapshot of the ongoing process.
kill pid – Kill process with that particular process ID
pkill name – Kill process with the name.

No comments:

Post a Comment