首页 > 系统相关 >Basic Linux User Guide

Basic Linux User Guide

时间:2023-01-23 21:47:16浏览次数:65  
标签:name tar command user file Linux directory Guide User

Normal Ubuntu User Guide!

Concepts

  • Everything is file.

  • Open source.

Useful knowledge

.desktop file - short icon

A .desktop file is simply a shortcut that is used to launch applications
in Linux. Without the .desktop file, your application won’t show up in
the Applications menu and can’t be launched with third-party launchers
such as Ulauncher and Albert

# create desktop file
# Store .desktop file to .local/share/applications/ 

[Desktop Entry]
Type=Application
Name=Personal File
Exec=/home/user/file
Icon=gedit

add pinyin

Note: These instructions are ONLY meant for vanilla Ubuntu and ONLY for 22.04 for basic pinyin input for simplified characters.

Ubuntu has never provided an easy, well-documented option for adding
pinyin input support. However, to get basic pinyin support in 22.04 you
can simply:

  1. Open Settings, go to Region & Language -> Manage Installed Languages -> Install / Remove languages.
  2. Select Chinese (Simplified). Make sure Keyboard Input method system has Ibus selected. Apply.
  3. Reboot
  4. Log back in, reopen Settings, go to Keyboard.
  5. Click on the "+" sign under Input sources.
  6. Select Chinese (China) and then Chinese (Intelligent Pinyin).

You should now have a little "en" (or whatever the language code of your Ubuntu install is) at the top right of your main screen which you can click on and get a list of available input methods, including Chinese (Intelligent pinyin).
Open anything that can receive text (like gedit, openoffice, vim, FF,...) and try it out. You can also change between them with Super/Win + space.

  1. Reboot to make sure it is still there after a reboot.
  2. Be happy that you didn't lose any more time on this ridiculously trivial issue that is still a massive pain in 2022!

If you don't need extra bells and whistles then do NOT bother with fcitx (and the supposedly excellent "google pinyin"), uim or any other exotic option! They are extremely hit-and-miss trying to install, and finding a guide that is relevant to 22.04 is almost
impossible. Some claim to have "tested with 22.04" but they have done upgrades of previous versions that they had working, not fresh installs.

File System

Concepts

Disk

# report file system disk space usage
$ df -hT

# display a list of the file systems currently mounted
$ mount

# Mount some device on a new directory
$ mount -t _fs_type _source _diretory

# Unmount a device 
$ umount _source

Struct

SCOPE + CATEGORY + APPLICATION -- Linux Pocket GUide



Operates

# working directory path
$ pwd

# cd old pwd
$ cd - 

# cd current user's root directory
$ cd ~

# all, long, human-readable
ls -alh _directory

# determine file type
file _file

mkdir _name

cp _source _dest / _source... _directory

mv _source _dest / _source... _directory / _old_name _new_name

rm -iv _files... / -riv directory 

# create hard links(is backup)
ln _target _link_name

# create symbolic links(just a pointer)
ln -s _target _link_name

Using Bash

Concept of shell

  • The command-line user interface of the operating system

Features of bash

Expansions

# Command arguments will be expanded before execution

# 1. space & word splite expansion
$ echo a      b c  -> a b c

# 2. path-name expansion
# The mechanism by which wildcards(*) work is called pathname expansion.
$ ls * / $ ls *D / $ ls D* / $ ls /usr/*/bin


# 3. tilde(~) expansion
# expand to user root directory.
$ echo ~(current user) / $ echo ~xx_user_name

# 4. arithmetic expansion(+ - * / % **)
$ echo $((2**5)) 

# 5. brace expansion
{001..5} / a{A{1,2},B{1..5}}b

# 6. parameter expansion
$ echo $any_var_in_env

# 7. command substitution expansion
$ ls -alh $(which cp)  

Quoting

# limit expansion

# double quotes
# Allmost expansions can't work. The exceptions are $, \, and `.
# Use \$ \\ 

# single quotes
# All expansions can't work

Command help

$ type _buitin_command

# option
$ help / --help

$ man _command
$ whatis 

# locate a command
$ which 

# locate the binary, source, and manual page files for a command
$ whereis

# list all alias
$ alias

I/O Redirection

# stdoutput & truncate file
>

# stdoutput & error
&

# stdoutput & don't truncate file
>>

# stdinput
<

# concatenate files and print on the standard output
cat

# pipe, different with >,< to overwriting file
# just transfer result as command parameter
|

# omit repeated lines
uniq

sort

# print newline, word, and byte counts for each file
wc

# filter result 
$ dpkg -l | grep fire*

# !tail -f output appended data as the file grows
head/tail

# duplicating pipe content & write to stdoutput
tee

Keyboard Tricks

Editing

# Move cursor to the beginning or end of the line      
$ ctrl + a
$ ctrl + e

# Move cursor forward or backward one word
$ alt + f
$ alt + b

# Clear screen
$ ctrl + l

# cut text from the cursor location to the end or start of line.
$ ctrl + k
$ ctrl + u

# past 
$ ctrl + y

History

# list all history 
$ history

# !history_num to runing history command

# entery keyworld to seraching history
$ ctrl + r

Permissions

What is permissions ?

Each file has three types of permissions, owner, group, other. We just need to know what permissions we want to share to own group and others when we create the file.

Permission Operate

# change default permission 
# every file init permission is 0666, and using umask 0002 to mask bit.
$ umask [mode]

# change file permission
# using u(user), g, o(other), a(all) + - = , r w x to change file mode
$ chmod u+rwx 
$ chmod ug+rx, o=r
$ chmod g-x, o=r

# some special permission
# suid, guid, sticky bit
https://linuxhandbook.com/suid-sgid-sticky-bit/

# change owner or group owner
$ chown _new_owner:_new_group_owner


# run root user
# On Ubuntu, there is no root user account, just can use sudo command.
$ su - 

# run command as root
# commands that sudo can work is settled by /etc/sudoers
$ sudo _command

# list sudo privileges
sudo -l -U _user_name

Manage User

# print real and effective user and group IDs
$ id

# change user password
$ passwd 

# add new user
$ adduser _user_name

# Add a user group
$ addgroup [--gid ID] _GROUP  

# add new sudo user
# default user is not a sudoer,it not in sudo group that can't use sudo.
# just need append to sudo group
$ usermod -aG sudo _user_name

# delete user
$ userdel -rf _user_name

Processes manager

# viewing processes
# snapshot
$ ps aux

# dynamically
$ to

# controlling processes
# list process that start in the bash
$ jobs 

# running in the back ground
$ bg _%jobs_id

# running in the front ground
$ fg _%jobs_id

# linux uses sending signal to control process
# Stop
$ ctrl + z
$ kill -TSTP _pid
$ kill -STOP _pid # rude

# Terminate
$ ctrl + c
$ kill -INT _pid     # interrupt
$ kill [-TERM] _pid  # terminate
$ kill -KILL _pid    # rude

# continue, restore process that was stopped
$ kill -CONT _pid

Editor

vim

# enhanced behavior
$ echo "set nocp" >> ~/.vimrc

# editing mode or execute vim command(ready to set mode after enter esc)
1. i (INSERT MODE)
2. :w (save)
3. :q (quit)

# move cursor(must enter esc)
1. k -> up
2. j -> down
3. h -> left
4. l -> right
5. 0 -> line begin
6. $ -> line end
7. w -> next word
8. G -> end line

# basic editing(must enter esc)
# delete next n line(include cureent line)
ndd

# copy-past
0. p -> past
1. yy -> current line
2. nyy -> next n line
3. y$ -> from current location to line end
4. y0 -> from current location to line begin

# search
step1: /key_word
step2: enter (first match)
step3: n (next match)

# edit mode
# move cursor
# basic editing
# search  

Environment

Concept of environment

Global data for every program(include shell script), the data consist of environment var and shell var.

IMPORTANT VAR PATH: A colon-separated list of directories that are searched when you enter the name of a executable program

Default Environment

Environment will be established when startup shell

  1. Login shell session : /etc/profile, ~/.bash_profile or ~/.bash_login or ~/.profile

  2. Non-login shell session: /etc/bash.bashrc, ~/.bashrc

# list all env var
$ printenv

# Export environment to subsequently executed programs
export PATH

# list all alias
$ alias
$ alias _xx 'ls -alh'

Manage Environment Scheme

  1. PATH or define additional environment variables, place those change in .profile

  2. For everything else, place the change in .bashrc

Manage Software

# set software center mirror 
GUI: softwareupdate > 

# dpkg low tools 
$ dpkg -i/-r/-l 

# apt* hight tools
$ apt update   # update software index cache

# snap is interface of snap store.

Networking

Test tools

# ping
# traceroute

View information

# ip
$ ip a

# netstat
# check tcp connections
$ netstat -at

# check udp conections
$ netstat -au

Archiving and Backup

Compression

# gzip & bzip2 [option] [file]...
# -d decompression 
# -v verbose

Archiving

1. create a tarball
# !no - 
$ tar cvf _output_name.tar _source_directory

2. create a gzip tarball
$ tar cvzf _output_name.tar.gz _source_directory

3. create a bzip2 tarball
$ tar cvjf _output_name.tar.bz2 _source_directory

4. list the contents of a tarball
$ tar tvf _target.tar

5. add more files to a tarball
# you can't forward add file to compressed tarball
$ tar rvf _target.tar _update_directory

6. Extract a tarball
$ tar xvf _target.tar[.gz, .bz2]

7. Extract the tarball to a specific directory
$ tar xvf _target.tar -C _target_dir

标签:name,tar,command,user,file,Linux,directory,Guide,User
From: https://www.cnblogs.com/ivanohohoh/p/17065550.html

相关文章

  • archlinux连接Github与本地
    连接Github与本地首先右键打开gitbash,然后输入下面命令:gitconfig--globaluser.name"vconlln"gitconfig--globaluser.email"[email protected]"用户名和......
  • Linux Debian11安装QT6开发环境
    从Qt5.14开始,官方不提供离线安装包,只提供源码包和在线安装器。但是清华为我们提供了快速的在线安装方式。一.下载清华提供的在线安装器在线安装器下载链接二、给在线安装......
  • archlinux手机投屏
    多屏协同......
  • Linux下手工编译libiconv库的小问题
    我的电脑是Ubuntu14.04LTS,自己手工编译php5.6,打开ZEND_EXTRA_LIBS='-liconv'时,发现没有安装libiconv,也就是编码转换的库,所以百度该库的安装方法,如下:......
  • 无法加载文件 C:\Users\Administrator\Desktop\spider01\venv\Scripts\activat
    遇到问题原因Restricted(防止运行没有数字签名的脚本),要设置成remotesigned模式解决方案输入get-executionpolicy以管理员的方式打开Powershall运行,并在命令窗......
  • 【ubuntu基础】linux常用命令总结
    前言 常用命令查看cpu内存使用情况tophtop 解压文件至某个目录tar-zxvfaaa.tar.gz-C/path/to/untar/​​ 删除size为0的文件​​find.-name"*"-typef-size0c......
  • Linux系统编程—进程(作业+答案)
    文章目录​​程序和进程​​​​并发​​​​单道程序设计​​​​多道程序设计​​​​CPU和MMU​​​​进程控制块PCB​​​​环境变量:​​​​常见环境变量​​​​PATH......
  • 面试常问的21条Linux命令
    本文章总结了21条最频繁使用的Linux命令,也是面试官考察你对Linux系统熟不熟常问的面试题,可以收藏本文章,作为一个Linux命令速查手册。文章目录​​一、文件和目录​​​​二......
  • 小米-红米(Redmi)-note刷 Linux系统(二)【下载、备份篇】
    上一篇:小米-红米(Redmi)-note刷Linux系统(一)【基础篇】下一篇:小米-红米(Redmi)-note刷Linux系统(三)【下载准备篇】 要想不变砖,备份要在前。重要事情说3遍。先备份!!!先......
  • 小米-红米(Redmi)-note刷 Linux系统(三)【准备篇】
    上一篇:小米-红米(Redmi)-note刷Linux系统(二)【下载、备份篇】下一篇:小米-红米(Redmi)-note刷Linux系统(四)【篇】 一、开启USB调试模式设置--关于手机,点击7次“M......