Linux1: Getting to know Linux for the first time (related concepts, Ubuntu installation, Linux directory, shell command, parameter transfer program)

Linux1: Getting to know Linux for the first time (related concepts, Ubuntu installation, Linux directory, shell command, parameter transfer program)

Getting to know Linux for the first time:
1.C
2.STM32
3.LINUX operating system
4. Driving Linux system has nothing to do with 32

1. Related concepts
Operating system
Reasons
With the development of hardware, simple bare-metal programs cannot meet the utilization of hardware.
The bare-metal drivers written by each person are different, which leads to trouble
in writing the application layer. Function
Manage software and hardware resources (manage hardware resources to provide convenient operation interfaces for the application layer)

Common operating system
unix: the current mainstream multi-user, multi-tasking operating system
PC workstations, servers, supercomputers
windows: 90% of the personal computer user market
linux: open source free, IT industry
IOS/MAC: Apple
ucos Vxworks wince, etc.: small Embedded operating system
Ubuntu system
Version classification
Desktop version (desktop)
Server version (Server)
use version
Ubuntu Server 16.04.4 LTS
version introduction
Server
server version
LTS
Long Term Support
long-term support version
Ubuntu features
based on Linux operating system, free community and professional Institutional support
Use APT package management system
Provide online installation and upgrade
Software update

Operating system:
windows Linux Android IOS Saipan
Linux operating system function?
Resource management, hardware management, file management,
operating system links software and hardware. When
these softwares run, they are a process
ROM: read-only memory, not lost when power off
RAM: random access memory, lost when power off
Five major functions of the kernel:
1. Hardware management
2. File Management
3. Process management
4. Network management
5. Memory management
Windows operating system:
XP win7 win8 win10
Linux operating system
Ubuntu Red Hat
Ubuntu installation
Category: Desktop version Server version
12.04 16.04 18.04 (64): From now on are 64-bit 20.04
63 Bit compatible with 32-bit
Ubuntu Features:
Based on Linux operating system, free support from the community and professional institutions
Provide API package management system
Provide online installation and upgrade

2. Ubuntu cheap

Directly install the Ubuntu operating system,
install windows and Ubuntu dual systems,
use virtual machines
1- install software that simulates virtual machines under windows (vmware workstation, v-box)
2- create virtual machines
3- install operating systems for virtual machines
4- install vmware tools Tool
allows the mouse to switch back and forth,
can paste and copy files from windows

3.Linux directory:
Linux everything is a file under the
device node: / dev /
general user
administrator user
something in the root directory only an administrator can modify the
vim gedit vi
they are editors
gcc:
Compiler
path: Save the file location
relative path: relative to the current In terms of path,
absolute path: relative to the root directory/

4.shell command:
Shell command
command prompt
user@ubuntu:~$ is the command prompt
@ The part before is the current user
@ and the part between: is the host name
: and the part between $ is the current path
command What is
special The functional program, an interface between the user and the core program of the operating system.
How to learn the instruction
man online manual The
manual page varies greatly in detail and quality
man + instruction
man manual first page
man + function name
man manual second page or The third page
info command
browses all documents online.
Command --help
Why learn commands.
Command operation is fast (batch processing).
Linux interface is relatively simple.
Character operation interface developers use the
basic command operation.
Format description The
command format with [] means optional, Others are required options.
Command [Options] [File name…]
Shortcut operation
Wildcard
*
represents all
? It
means that the position can be any single character
Command completion
tab
basic command
user management command
Add a user account
sudo adduser xxx This command will add an account in the home directory.
Create a user, which can only be created by the administrator.
After the creation is completed, there will be a home directory in the home directory. The
user switches
su and the user name is
changed to another user identity. To turn a normal user into a super user, and password input is required.
Delete user
Delete:
terminal method: use newuser to replace the user account you want to delete.
Under root user: userdel -rf newuser
Under ordinary user: sudo userdel -rf newuser
because of you The user needs to be completely deleted, so add the -rf option to delete the user's home directory and mail directory at the same time as the user is deleted.
Login to all users of the system
who
file directory-related command
ls
function
displays a list of files in the current directory
Red: archive
blue: Directory
Green: Executable
Black: Common File
Format
ls [option] ... [file] ...
Options
- l
using a long format list information
file types and links to the file owner permissions file modification time of the file size is a group name of
the file types: an ordinary file
directory (D)
a symbolic link (l)
Block device (b)
character device file (c)
named pipe (p)
socket file (s)
ordinary file (-)
-a
displays all files under the current file.
Hidden files start with. (Where. And... Special)
.: current directory...: the upper level directory
cd
function to
switch the working directory to the target directory
Format
cd [FILE]
commonly used
cd to enter the user's home directory;
cd ~ to enter the user's home directory;
cd-return to the directory before entering this directory ;
Cd… return to the upper-level directory (if the current directory is "/", it will still be "/" after execution; "..." means the upper-level directory);
cd …/... return to the upper two-level directory;
cd !$ put on The parameters of each command are used as cd parameters.
mkdir
function
create directory
format
mkdir [options] directory
option
-m
-m <target attribute> or -mode <target attribute> set the permissions of the directory while creating the directory
-p
if the upper directory of the directory to be created has not been created yet, it will be And establish the upper directory
touch
function to
create file
format
touch [option] file is
similar to
touch file name // create a file, but do not open
echo> file name // create a file, but do not open the
vim file name // if the file name exists, open
it directly, otherwise create and open
gedit file name/ / If the file name exists, directly open,
or create and open
rm
function
deletes a directory of one or more files or directories
format
rm [options] [file]
option
-r
recursive delete
-f
without prompting delete
cp
function
will One or more source files or directories are copied to the specified destination file or directory.
Format
cp [option] source file directory.
Option
-f
forces to copy files or directories, regardless of whether the target file or directory already exists
-r
recursively copy
-l
to source files Establish a hard link instead of copying files
mv
function
Rename files or directories, or move files from one directory to another.
Format
mv [Options]... Source files... Directory
options
-b: When the file exists, create a backup for it before overwriting;
-f: If the target file or directory is the same as the existing file or directory, then directly overwrite the existing file or directory;
./ Execute
package compression
* .zip
unzip decompression
*.gz
gzip file (file) compression
gunzip decompression
.bz2
bzip2 file (file) compression
bunzip2 decompression
tar
tar [] the file name after packaging .tar file directory list
tar -cvf xxx.tar xxx (directory to be packaged ) Pack the directory into a file
tar -xvf xxx.tar Unpack
tar -cvzf xxx.tar.gz xxx Pack and compress the directory into a file
tar- xvzf xxx.tar.gz Unpack
tar -xvf xxx.tar.gz -C Path //Unzip the xxx.tar.gz compressed package to the specified path
History command
history
cat $HOME/.bash_history
System management command
ps
ps [] View the list of processes run by the user in the current system
-ef View the process and process number, system time, Command detailed directory, executor, etc.
-aux displays the CPU and occupancy process status on the basis of -ef (list all the programs currently in memory)
top
View the resource usage of the process
shutdown
sudo shutdown -h now Shut down immediately
uptime
shows how long the system has been running
Network management command
ifconfig //View network configuration
ifconfig eth0 ip configuration ip
ifconfig eth0 down Pause the network card
ifconfig eth0 up Turn on the network card
/etc/init.d/ networking restart //Restart the network configuration
ping xxxIP address //Test the connectivity
link of the ip address ln
set the link (shortcut)
ln -s target file link name//shortcut
ln source file target file//delete the original file to the target file Does not affect
other commands
cat to
view files.
For example: cat 1.c
specified folder to search for specific information
[root@www ~]# grep [-acinv] [–color=auto]'Search string' filename
options and parameters:
-c: Count the number of times that
the'search string' is found -i: Ignore the difference in case, so the case is regarded as the same
-n: output the line number by the way
-v: reverse selection, that is, show that there is no'search string' content That line!
--Color=auto: You can add color to the key words found.
grep "string" File and path
Search file
find path [Option] Description
-name supports wildcards

to find files according to information
-name
to find files by name
-type ( Example: find /xxx/xxx xxx -type d)
According to the file type to find (f file, d directory, l soft link file)
-size (Example: find /xxx -size +204800c (find files larger than 204800 bytes ( c: byte, w: double word, k: KB, M: MB, G: GB)))
according to the file size search, +, -: greater than the set size, direct write size is equal (-: sign is less than)
-user (Example: find /xxx -user user1)
Find all files of the owner of the user name
Change permissions
chmod permissions file
echo echo
command
Software installation
DPKG
installation deb format pre-compiled software package package file
dpkg -i | --install xxx.deb Install the deb software package
dpkg -r | --remove xxx.deb Remove the software package
dpkg -r -P | --purge xxx.deb Delete the
dpkg -I | -info xxx.deb along with the configuration file to view the software package information
dpkg -L xxx.deb View the files in the package
dpkg -l View the information of the installed software packages in the system
APT
apt-get
apt-get install xxx Install xxx
apt-get remove xxx Uninstall xxx
apt-get upgrade Perform system upgrade
apt-get update Update the software information database
apt-cache
apt-cache search Search the software package
DPKG and APT The difference between the
two is that dpkg bypasses the apt package management database to operate the software package, so the software package you have installed with dpkg can be installed again with apt Once again, the system does not know that it has been installed before and will overwrite the previous installation of dpkg.
1. dpkg is used to install .deb files, but it does not solve the dependencies of modules and does not care about the software in the ubuntu software warehouse. It can be used to install local deb files.
2. Apt will solve and install the dependency problem of the module, and will consult the software warehouse, but will not install the local deb file, apt is a software management tool built on dpkg.

5. Passable parameter program

Passable program
int main(void)
int main(int argc,char *argv[])
argc: the number of command line parameters argv: record the number of command line parameters
int argc the
number of parameters
char *argv[]
command line input the parameter is a string passed in
the argv [0] ---------./a.out
the argv [. 1] ----- incoming real parameter values
char * argv [] = { "HELLO" ,"ASD"}
Insert picture description here

Reference tree: You need to download the xmind software to view
Linux
for the first time
Class Notes:
First try Linux

Guess you like

Origin blog.csdn.net/weixin_40734514/article/details/108762847