Linux / Ubuntu CLI(Command Line Interface) for beginners

daaahailey

Dahye Ji

Posted on November 24, 2021

Linux / Ubuntu CLI(Command Line Interface) for beginners

What is Ubuntu and Linux?

To start with, I had the same question myself because I had no idea so I am adding this link.
What is difference between Ubuntu and Linux?
Linux as an operating system (although it is actually a kernel but we don't need to get into that

Linux

Just like Windows, iOS, and Mac OS, Linux is an operating system. In fact, one of the most popular platforms on the planet, Android, is powered by the Linux operating system. An operating system is software that manages all of the hardware resources associated with your desktop or laptop. To put it simply, the operating system manages the communication between your software and your hardware. Without the operating system (OS), the software wouldn't function.
Kernel – This is the one piece of the whole that is actually called Linux. The kernel is the core of the system and manages the CPU, memory, and peripheral devices. The kernel is the lowest level of the OS.

Ubuntu

Ubuntu is a complete Linux operating system, freely available with both community and professional support.

Ubuntu is a Linux distribution.
Distribution is an operating system made from a software collection that is based upon the Linux kernel.
So, Ubuntu is Operating system built on Linux.(if you click their names, you can go to their website and find out more about them)

At the class, we practiced using command line using goorm ide!
goorm is cloud-based ide(integrated development environment) and they use Amazon EC2(Amazon Elastic Compute Cloud)for their service.

Command Lines for beginners

mkdir make directory
mkdir -p /one/two/three make directory three inside two and one inside two
mkdir one two three make directory one, two, three
cd change directory
*You can change the working directory using the cd command
cd nameofdirectory go to the directory typed after cd
cd .. go up to the parent directory
cd / using “/” at the start of your path means “starting from the root directory” so it goes to root directory
cd ~ character (”~”) at the start of your path similarly means “starting from my home directory”.
pwd print working directory(use this when you don't know where you are at currently, it will show you your working directory)
ls print file list of current directory
ls -a all, print all of the files including hidden files of current directory
ls -al it's like mix of ls -a and ls -l. It prints more detailed data including file permission, size, etc. Also ll is the same as ls -al
ls *.txt print every files that file extension is .txt
alias is a command making shortcut.
alias ls="ls -a" this makes ls as a shortcut of ls -a
You can undo this by unalias ls
touch filename create file named filename (i.g: touch test.txt will make txt file named test)
touch test1.txt test2.txt create test1.txt and test2.txt
touch test1.txt;test2.txt
create test1.txt and test2.txt (You can put two or more commands on the same line separated by the semicolon. ; means - if the previous command fails, still execute the next command. && means - execute the next command only when the previous command was executed successfully
& makes the command run in the background
mkdir one;cd one make directory one and go to directory called one (it executes at once)
echo "This is a test" print "This is a test"
echo "hello world" > hello.txt save "hello world" in hello.txt (So, this saves the echo result inside hello.txt that gets created by this command)
cat hello.txt it prints "hello world"

$echo "nice to meet you" > greeting.txt
$cat greeting.txt
nice to meet you

$echo "i like blue" > one.txt
$echo "i like black" > two.txt

$cat one.txt two.txt
i like blue
i like black
Enter fullscreen mode Exit fullscreen mode

cat music.txt > song.txt
save content of music.txt to song.txt and it prints the content of song.txt
If you use >> instead of >, it will add the new content at the end of existent content of the file not replacing the content
mv move
mv test1.txt dir1 move test1.txt file to a directory named dir1
mv test.txt new-test.txt move test.txt file to new-test.txt and test.txt disappears.(It's like changing file name)
cp copy
cp one.txt two.txt create another copy of the file, in our working directory but with a different name(two.txt)
cp test.txt | grep "JavaScript" opens text.txt and find text of "JavaScript"
cp hello.txt dirname
copy hello.txt in the directory named dirname
find . -name '*.txt' find every file that file extension is .txt and print where it is.
rm remove
rm filename remove file named filename
rm dirnameremove directory named dirname(but it won't work if there's file inside dirname)
rm -r dirnamethis will delete directory named dirname even if there are files inside
-r means remove directories and their contents recursively.

💖 💪 🙅 🚩
daaahailey
Dahye Ji

Posted on November 24, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related