0% found this document useful (0 votes)
2 views7 pages

Introduction To Linux

Uploaded by

Nataly Medina
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views7 pages

Introduction To Linux

Uploaded by

Nataly Medina
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Introduction to Linux – Semiconductor testing

CETYS Universidad
Linux is a powerful operating system widely used for development, servers, and embedded systems. Unlike
Windows or macOS, it relies heavily on the command line interface (CLI) for system management,
automation, and scripting.

Windows users can start with Windows Subsystem for Linux (WSL), this allows Windows users to run a Linux
environment natively without needing a virtual machine or dual boot. It provides access to Linux tools,
command-line utilities, and even GUI applications while integrating seamlessly with the Windows file
system. It is great for developers who need a Linux workspace for programming, automation, or server
management while staying on Windows.

How to install WSL on Windows?

 Open command prompt as administrator and run the command wsl --install as follows:

 Follow the instructions (user and password for this new computer)
 After this, you may initialize the Linux Distribution: run the command wsl.exe –d Ubuntu:

Mac users can use the macOS Terminal like a Linux environment because macOS is Unix-based, but for a
true Linux experience, Mac users can use Docker (it runs linux containers) as follows:

How to install Docker on macOS?

 Download Docker Desktop from the official site: https://www.docker.com/products/docker-


desktop/
 Open the downloaded .dmg file and drag Docker to the Applications folder.
 Launch Docker Desktop, and wait for it to start (you’ll see the whale icon in the menu bar).
 Verify installation by running the following command: docker --version.
Introduction to Linux Commands

The Terminal allows users to interact with the system through commands, enabling them to manage files,
install software, and monitor processes efficiently.

With just a few basic commands, you can navigate directories, manage files, monitor processes, and even
control system settings. The following is a basic introduction to essential Linux commands to help you
navigate and manage the system.

1. SUDO

sudo is a program for Unix-like computer operating systems that allows users to run as super users.

2. NANO

Is a text editor for Unix-like computing systems or operating environments using a command line interface.

3. DIRECTORIES

Useful commands:

 cd into each directory.


 Use ls to list the contents of the directory.
 If you see an interesting file, use the file command to determine its contents.
 For text files, use less to view them.

Example

cd /etc change to the /etc directory

ls list the files inside /etc

file hosts identify the type of the file hosts

less hosts view the contents of hosts using less

Linux directories

Linux follows a structured file system hierarchy, where everything is organized into directories. Unlike
Windows (which uses drive letters like C:\), Linux has a single root directory (/) that contains all other
folders.
Some key system directories include:

Directory Description
/ The root directory where the file system begins. In most cases, the root directory
only contains subdirectories.
/boot This is where the Linux kernel and boot loader files are kept. The kernel is a file
called vmlinuz.
/etc The /etc directory contains the configuration files for the system. All of the files
in /etc should be text files. Points of interest:

/etc/passwd
The passwd file contains the essential information for each user. It is here that
users are defined.
/etc/fstab
The fstab file contains a table of devices that are mounted when your system
boots. This file defines your disk drives.
/etc/hosts
This file lists the network host names and IP addresses that are intrinsically known
to the system.
/etc/init.d
This directory contains the scripts that start various system services typically at
boot time.
/bin, /usr/bin These two directories contain most of the programs for the system. The /bin
directory has the essential programs that the system requires to operate, while
/usr/bin contains applications for the system's users.
/usr/local /usr/local and its subdirectories are used for the installation of software and
other files for use on the local machine. What this really means is that software
that is not part of the official distribution (which usually goes in /usr/bin) goes
here.

When you find interesting programs to install on your system, they should be
installed in one of the /usr/local directories. Most often, the directory of
choice is /usr/local/bin.
/root This is the superuser's home directory.
/dev It contains devices that are available to the system. In Linux (like Unix), devices are
treated like files.

4. MANIPULATING FILES

Useful commands:

 cp - copy files and directories


 mv - move or rename files and directories
 rm - remove files and directories
 mkdir - create directories
CP: Copies files and directories:
cp file1 file2
cp file... directory

MV. Moves or renames files and directories depending on how it is used


mv filename1 filename2
mv file... directory

RM. Removes (deletes) files and directories


rm file1
rm -r dir1

MKDIR. Used to create directories


mkdir directory

5. UNPACK .TAR FILES


tar zxvf filename.tar.gz

6. INSTALL AND UPDATE SOFTWARE PACKAGES

sudo apt-get update Fetches the list of available updates

sudo apt-get upgrade Strictly upgrades the current packages

sudo apt-get dist-upgrade Installs updates (new ones)

7. CREATING AND COMPILING C PROGRAMS

a. To start, open the Nano text editor and create a new file with a “.c” extension by entering this
at the command prompt:
sudo nano hello-world.c
b. Implement the following code:
#include <stdio.h>
int main()
{
printf("Hello, World! \n");
return 0;
}

c. After entering the code, enter Ctrl-X and Y to save and exit nano.
d. To compile:
gcc hello-world.c -o myfirstcprogram

e. To execute the program:


./myfirstcprogram

8. CREATING AND COMPILING JAVA PROGRAMS

 Install Java JDK by running the following command: sudo apt install opendk-17-jre-headless, then
press Y as follows:
 Verify the installation with java –version

 Set JAVA_HOME environment variable

To determine the exact path for JAVA_HOME, run the following command: update-alternatives –config java

Once you have the path, you can set the JAVA_HOME variable. Assuming the output was /usr/lib/jvm/java-
17-openjdk-amd64.

After updating the file, apply the changes confirm that JAVA_HOME is set correctly, run the following
commands:

Install the full JDK with:

sudo apt install openjdk-17-jdk

 Write a simple java program

Create a new directory for your Java projects:

Create a file named Helloworld.java

nano Helloworld.java
Add the following code:
public class Helloworld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}

Press ctrl+O and then ctrl+X to exit.

Compile the Java program:

javac Helloworld.java

Run the program:

java Helloworld.java

You might also like