Fundamentals of Computer Science
Fundamentals of Computer Science
Computer Science
Introduction to Linux Basic Commands &
Environment
What is Linux
Linux is an operating system that evolved from a kernel
created by Linus Torvalds
both have a similar design but are less both have a similar design but larger and
Kernels complex. more complex than the Linux kernel.
On the other hand, Linux is widely used on Unix is typically found on enterprise-level
Availability both enterprise and personal computers. servers and workstations and is less
commonly used on personal computers.
What is Linux
Linux is an operating system that evolved from a kernel
created by Linus Torvalds
bug fixing recognition and solution is very fast require longer up time, to get the best
time possible bug-fixing,and a patch.
Source Code The source is accessible to the general public. The source is not accessible to the general
Availability public.
1 Server
2 Desktop
3 Workstation
4 Routers
5 Embedded devices
6 Mobile devices (Android is a Linux-based
OS)
Many software vendors release their own packaged
Linux OS (kernel, applications) known as distribution
Types of Shell
sh
csh
ksh
bash
Tcsh Reading assignment
Directory Structure
All files are arranged in a hierarchical structure, like
directory /
Navigation of the Command Line
Root Directory – the top-most directory in a file system structure
Home Directory – the file system directory for a given user on
an operating system
Current working directory – the directory in which the user is
currently in
Absolute path – the path of a file from the root directory
Relative path – the path of a file from the current working
directory
File system structure – the organization of the files and
directories of a compute
Using the Terminal
Open terminal
System Info
date Show the current date and time
cal Show this month's calender eg cal -3/cal -j
uptime Show current uptime
uname –a Show kernel information
man command Show the manual for command
df Show the disk usage
du Show directory space usage
free Show memory and swap usage
whereis app Show possible locations of app
+
+
User
Create new user
User add username----useradd aau
Change password
Sudo password username-----sudo password aau----
Delete user
Userdel username ----------userdel aau
Copy directory
Delete directory
rmdir - Remove an existing directory
rmdir c---- this code remove a directory called c
rm -r Removes directories and files within the directories
recursively.
Creating file
touch Create empty file
eg touch file 3
touch file1 file 4
Rename file
MV---- change the name of a file
Cp text2.txt AAU this code copy file text2.txt to directory AAU folder
Cp text2.txt text11.txt If text11.txt is text file the statement replace and
copy on it
Delete File
cmp Tells you if two files are different and where the first difference appears
wc word counts newlines, words and bytes of a file
eg. wc text2.txt
What is a link?
similar.
Now any time you edit any of those files, the content will be updated for both.
If you delete the original file, the link will still contain the original file
content, as that's not removed until there is one hard link pointing to it.
Soft links Soft links
They are more powerful as you can link to other filesystems and to
directories, but when the original is removed, the link will be
broken.
You create soft links using the -s option of ln :
Eg. Ln –s file1.txt newfile.txt
In this case you can see there's a special l flag when you list the file using ls
-al , and the file name has a @ at the end, and it's colored differently if you
have colors enabled:
remove duplicate lines
Cat> fruit
Apple
Orange
Create a file with name Fruit
Banana
Apple
Grasp
file. Its name comes from the past and means tape archive. Back when archives
were stored on tapes. This command creates an archive named archive.tar with
the content of file1 and file2 : tar -cf archive.tar file1 file2
More on Linux command read from the link
https://www.javatpoint.com/linux-directories