欢迎加入QQ:498903810 一起交流、讨论知识,里面有大佬,也有小白,天下码农一家亲,大家一起讨论进步。

linux的行提示符:[[email protected] Desktop]$ 

student ##表示当前登陆的用户

@ ##分隔符

localhos t##表示主机名

Desktop ##表示当前工作目录

$ ##身份提示符,表示当前用户是普通用户,如果是'#'表示当前用户是管理员

注意:命令要在行提示符之后输入才能执行。

Linux C/C++开发工程师之路(1)

Linux C/C++开发工程师之路(1)

linux两种不同的切换登陆方式

        方式一、通过系统的登出,重新选择用户

        方式二、通过shell终端,命令行切换

使用命令:su - username

Linux C/C++开发工程师之路(1)

username表示你要切换到的用户名,su是switch user的缩写,本义就是选择用用户的意思

如果在命令行下登陆系统,

login ##输入你要登陆的用户的用户名

passwd ##代输入用户的登陆密码


命令的执行

1、命令必须在命令提示符之后输入;

2、命令的格式

命令 参数 目标

##命令、参数、目标三个之间都有空格分开,否则命令不会执行

例:ls -l /etc/

Linux C/C++开发工程师之路(1)

3、假如已经输入一段很长的命令,但又懒得去删除他了,或者,想中之某个命令,那么可以使用

Ctrl + C ##取消该命令的执行,或者中断某个命令。

Linux C/C++开发工程师之路(1)

4、参数的格式分为两种情况,

-参数    ##加一个横杠的表示该参数是某个参数单词的缩写,

--参数   ##加两个横杠表示该参数是某参数单词的全拼

Linux C/C++开发工程师之路(1)

查看某命令的相关帮助和用法

1、whatis 命令  ##查看该命令的功能

Linux C/C++开发工程师之路(1)

2、命令 --help   ##查看该命令的帮助

Linux C/C++开发工程师之路(1)

3、[ ] ##表示该位置的内容,可以添加也可以不添加

4、... ##加入的内容是任意多个

Linux C/C++开发工程师之路(1)

5、<> ##表示该命令在执行的过程中,必须要加,否则该命令无法执行

Linux C/C++开发工程师之路(1)

系统的基本使用

系统登陆

  gnome--session-quit --force ##强制注销用户

--logout ##登出当前用户

--power-off ##关机

--reboot ##重新启动

--no-prompt ##立即注销用户

工作界面的切换

Ctrl + alt + 上/下

开启终端

Applications --> Utlities --> Terminal

Linux C/C++开发工程师之路(1)

鼠标右键 --> open in terminal

Linux C/C++开发工程师之路(1)

gnome-terminal

Ctrl + shift + n ##在新窗口打开一个shell, n:new

Ctrl + shift + t ##在当前窗口在打开一个新的shell ,t:tab

exit / Ctrl + d 推出当前shell

系统的开关机器

reboot / init 6 / shutdown -r now 均为重启电脑

poweroff / init 0 / shutdown -h now 均为关机

电脑的锁屏

Ctrl + alt + L ##在rhel 7.0中

win键 + L      ##在rhel 7.2中

简单的命令使用介绍

date ##显示当前系统时间,Ctrl + c 推出监控模式

##  -n, --interval <secs>  seconds to wait between updates

watch -n 1 date ##-n 是参数,后面的必须带参数,表示每秒执行几次后面的命令,date

##该语句的命令每秒执行一次date命令,则该命令可以用来现实系统时间

Linux C/C++开发工程师之路(1)

date ##通过 date --help命令可以查询到该命令的用法和选项参数,或者使用 man date

##的命令参数

Linux C/C++开发工程师之路(1)

 -d, --date=STRING         display time described by STRING, not 'now'

  -f, --file=DATEFILE       like --date once for each line of DATEFILE
  -I[TIMESPEC], --iso-8601[=TIMESPEC]  output date/time in ISO 8601 format.
                            TIMESPEC='date' for date only (the default),
                            'hours', 'minutes', 'seconds', or 'ns' for date
                            and time to the indicated precision.
  -r, --reference=FILE      display the last modification time of FILE
  -R, --rfc-2822            output date and time in RFC 2822 format.
                            Example: Mon, 07 Aug 2006 12:34:56 -0600
      --rfc-3339=TIMESPEC   output date and time in RFC 3339 format.
                            TIMESPEC='date', 'seconds', or 'ns' for
                            date and time to the indicated precision.
                            Date and time components are separated by
                            a single space: 2006-08-07 12:34:56-06:00
  -s, --set=STRING          set time described by STRING
  -u, --utc, --universal    print or set Coordinated Universal Time (UTC)
      --help     display this help and exit
      --version  output version information and exit

##输出格式

%%   a literal %
  %a   locale's abbreviated weekday name (e.g., Sun)
  %A   locale's full weekday name (e.g., Sunday)
  %b   locale's abbreviated month name (e.g., Jan)
  %B   locale's full month name (e.g., January)
  %c   locale's date and time (e.g., Thu Mar  3 23:05:25 2005)
  %C   century; like %Y, except omit last two digits (e.g., 20)
  %d   day of month (e.g., 01)
  %D   date; same as %m/%d/%y
  %e   day of month, space padded; same as %_d
  %F   full date; same as %Y-%m-%d
  %g   last two digits of year of ISO week number (see %G)
  %G   year of ISO week number (see %V); normally useful only with %V
  %h   same as %b
  %H   hour (00..23)
  %I   hour (01..12)
  %j   day of year (001..366)
  %k   hour, space padded ( 0..23); same as %_H
  %l   hour, space padded ( 1..12); same as %_I
  %m   month (01..12)
  %M   minute (00..59)
  %n   a newline
  %N   nanoseconds (000000000..999999999)
  %p   locale's equivalent of either AM or PM; blank if not known
  %P   like %p, but lower case
  %r   locale's 12-hour clock time (e.g., 11:11:04 PM)
  %R   24-hour hour and minute; same as %H:%M
  %s   seconds since 1970-01-01 00:00:00 UTC
  %S   second (00..60)
  %t   a tab
  %T   time; same as %H:%M:%S
  %u   day of week (1..7); 1 is Monday
  %U   week number of year, with Sunday as first day of week (00..53)
  %V   ISO week number, with Monday as first day of week (01..53)
  %w   day of week (0..6); 0 is Sunday
  %W   week number of year, with Monday as first day of week (00..53)
  %x   locale's date representation (e.g., 12/31/99)
  %X   locale's time representation (e.g., 23:13:48)
  %y   last two digits of year (00..99)
  %Y   year
  %z   +hhmm numeric time zone (e.g., -0400)
  %:z  +hh:mm numeric time zone (e.g., -04:00)
  %::z  +hh:mm:ss numeric time zone (e.g., -04:00:00)
  %:::z  numeric time zone with : to necessary precision (e.g., -04, +05:30)
  %Z   alphabetic time zone abbreviation (e.g., EDT)

passwd ##修改用户密码,设置用户密码的的命令

普通用户直接输入passwd + 回车 会修改当前用户的密码

管理员用户输入 passwd + 用户名 + 回车 会修改某用户的登陆密码,

Linux C/C++开发工程师之路(1)

  -k, --keep-tokens       keep non-expired authentication tokens
  -d, --delete            delete the password for the named account (root only)
  -l, --lock              lock the password for the named account (root only)
  -u, --unlock            unlock the password for the named account (root only)
  -e, --expire            expire the password for the named account (root only)
  -f, --force             force operation
  -x, --maximum=DAYS      maximum password lifetime (root only)
  -n, --minimum=DAYS      minimum password lifetime (root only)
  -w, --warning=DAYS      number of days warning users receives before
                          password expiration (root only)
  -i, --inactive=DAYS     number of days after password expiration when an
                          account becomes disabled (root only)
  -S, --status            report password status on the named account (root
                          only)
  --stdin                 read new tokens from stdin (root only)

file + 文件名 ##查看文件的类型

Linux C/C++开发工程师之路(1)

文件的查看常用命令

cat        filename    ##显示文件的全部内容
less        filename        ##分页浏览,按“q”退出,空格浏览下一页,"b"查看上一页
head        filename    ##显示一个文件的前几行
head -n 5    filename    ##前五行
tail        filename    ##显示文件后几行
tail -n 5     filename    ##显示一个文件的后5行

统计文件容量信息命令wc(word count)

Linux C/C++开发工程师之路(1)

 -c, --bytes            print the byte counts
  -m, --chars            print the character counts
  -l, --lines            print the newline counts
      --files0-from=F    read input from the files specified by
                           NUL-terminated names in file F;
                           If F is - then read names from standard input
  -L, --max-line-length  print the length of the longest line
  -w, --words            print the word counts
      --help     display this help and exit
      --version  output version information and exit

神兵利器 tab

tab并不是一个命令,它是键盘上的一个按键,具有补齐命令和文件名的作用

如果已经输入的信息可以找到唯一确定的命令或者文件名,那么按下tab会自动补全

如果不能找到唯一确定的命令或者文件名,那么按两下那么会列出可能的命令和文件名。

history命令

history ##现实执行过的命令

Linux C/C++开发工程师之路(1)

history -c ##会清除执行过的命令,但是并没有真正的删除,如果需要完全删除则需要删除记录历史命令的文件

!数字 ##执行曾经执行过的第 n 个命令

!字母 #执行最近一个以该字母开头的命令

Ctrl + R + 关键字 ##执行最近一条含有这个关键字的命令

键盘的上下键 ##逐行调用执行过的命令

linux的快捷键

左右            ##一个字符一个字符移动
ctrl +左右        ##一个字一个字移动
ctrl    + a         ##光标移动到行首
        + e         ##光标移动到行尾
        + u         ##光标所在位置删除到行首
        + k         ##光标所在位置删除到行尾
        + r + 关键字    ##调出最近一条含有关键字的命令
        + c         ##撤销以输入的命令
        + d         ##关闭当前环境
        + L        ##清空屏幕
        + shift + c    ##复制
        + shift + v    ##粘贴
        + shift + t     ##在现有shell中重新打开一个table        
        + shift + n    ##在shell中打开一个新的shell
        + shift + pageup|pagedown     ##切换table
        + alt + l          ## 锁屏
        + alt +上|下    ##切换工作界面
        + alt + f1|f7   ##进入图形界面
        + alt + f2-f6   ##进入虚拟控制台  














相关文章:

  • 2022-12-23
  • 2022-01-12
  • 2021-08-21
  • 2022-02-18
  • 2021-07-27
  • 2021-06-09
  • 2022-01-01
  • 2021-12-26
猜你喜欢
  • 2021-06-23
  • 2021-10-12
  • 2022-12-23
  • 2021-10-02
  • 2022-12-23
相关资源
相似解决方案