Linux及Git习题集

在这里插入图片描述

1.1 linux习题集

1、以容易理解的格式列出/home 目录中所有以”d”开头的文件目录的大小

rimideiMac-51:home admin$ ls -lh d*
desk:
total 56
-rw-------@ 1 admin  staff    26K 11 14 17:52 工作簿1.xlsx

desk1:
total 56
-rw-------@ 1 admin  staff    25K 11 14 17:52 工作簿2.xlsx 

2、列出/home 目录中所有以”s”开头的目录。

rimideiMac-51:home admin$ ls s*
str1:

str2:

str3:
rimideiMac-51:home admin$ 

3、删除后缀名为.log 的所有,删除前逐一询问

rimideiMac-51:home admin$ ls
desk		file1.log	file3.log	str2		test3
desk1		file2.log	str1		str3		工作簿3.xlsx
rimideiMac-51:home admin$ rm -i *.log
remove file1.log? y
remove file2.log? y
remove file3.log? y
rimideiMac-51:home admin$ ls
desk		str1		str3		工作簿3.xlsx
desk1		str2		test3

4、cp 命令 —n 和 -u的区别

cp -u 当把文件从一个目录复制到另一个目录时,仅复制 目标目录中不存在的文件,或者是文件内容新于目标目录中已经存在的文件。
cp -n 不要覆盖已存在的文件(使前面的 -i 选项失效)

5、找你的用户目录下面的所有py文件,ls -l 查看他们的属性,然后把这些结果输入到一个文件之中

rimideiMac-51:home admin$ ls /Users/admin|grep .py
txt.py

6、使用ls查看根目录 并且每行显示3个信息

rimideiMac-51:/ admin$ ls / | xargs -n 3
Applications Library Network
System Users Volumes
bin cores dev
etc home installer.failurerequests
net private sbin
tmp usr var

7、查看所有进程信息,只查看前3行

rimideiMac-51:/ admin$ ps x |head -n 4
  PID   TT  STAT      TIME COMMAND
  260   ??  S      0:00.37 /usr/libexec/UserEventAgent (Aqua)
  262   ??  S      0:02.58 /usr/sbin/distnoted agent
  264   ??  S      0:00.62 /usr/sbin/cfprefsd agent

8、分析以下问题,并给出解决方案

Mount is denied because the NTFS volume is already exclusively opened.
The volume may be already mounted, or another software may use it which could be identified for example by the help of the ‘fuser’ command.

通过错误语句的输出可以知道NTFS卷被拒绝是因为已经执行打开,可能已经被挂载或者有应用程序正在使用它,可以使用fuser命令显示正在使用指定的file,file system或者socket的进程信息,可以使用kill命令杀死该进程

9、ssh 服务端口是多少,ssh免密登录方式的原理是什么

rimideiMac-51:/ admin$ ls
rimideiMac-51:/ admin$ cd etc
rimideiMac-51:etc admin$ cd ssh
rimideiMac-51:ssh admin$ vim sshd_config
Port 22 (ssh服务端口)
ssh免密登陆原理:
rimideiMac-51:~ admin$ cd ~/.ssh
rimideiMac-51:/ admin$ ssh-keygen (生成公钥/私钥对)
rimideiMac-51:~ admin$ ssh-copy-id rimi@10.1.0.171(使用ssh-copy-id进行给公钥)

10.权限755代表什么权限,如果我想把所有的w权限去除应该使用什么命令

权限755代表用户读、写、执行权限都具有,及rwx,r为1,w为1,x为1

1.2git习题

1、git add和git stage的区别是什么

git add:作用是将您需要提交的文件添加到暂存区,需要提交的文件包括文件内容修改(modified)以及新文件(new),但不包括被删除的文件。
git stage:与git add区别不大,都是将需要提交的文件添加到暂存区

2、git rm --cached 和git rm -f的区别是什么

git rm --cached:默认情况下,git rm file 会将文件从缓存区和你的硬盘中(工作目录)删除。 如果要在工作目录中留着该文件,可以使用 git rm --cached
git rm -f:要删除之前修改过并且已经放到暂存区的文件,则必须使用强制删除选项,即git rm -f。这是一种安全特性,用于防止误删还没有添加到快照的数据,这样的数据不能被 Git 恢复。

3、git和svn的区别是什么

git和svn的区别:
1.gIT是分布式的,svn不是
2.git把内容按元数据方式存储,而SVN是按文件
3. ggt可以有无限个版本库,svn只能有一个指定中央版本库
4. git没有一个全局版本号,而svn有
5. git每个工作成员可以任意在自己的本地版本库开啟无限个分支;在svn,分支是一个完整的目录。且这个目录拥有完整的实际文件
6. 提交(Commit)在SVN,当你提交你的完成品时,它将直接记录到中央版本库。当你发现你的完成品存在严重问题时,你已经无法阻止事情的发生了。如果网路中断,你根本没办法提交!而Git的提交完全属於本地版本库的活动。而你只需“推”(git push)到主要版本库即可。Git的“推”其实是在执行“同步”(Sync)。

4、筛选出 2018.10.1 到 2018.10.20之间的日志,并且输出为地理图,并且没有做过合并

rimideiMac-51:xie_guoyi_homework admin$ git log --graph --since='2018.10.20' --after='2018.10.1'
* commit 6ee25d63646e0c7b20903712b8c8606fecf9cd60 (HEAD -> dev, origin/dev, master)
  Author: admin <admin@rimideiMac-51.local>
  Date:   Tue Nov 20 17:29:43 2018 +0800
  
      第一次作业

5、git init和git clone的区别

git init:将一个目录初始化为 git 仓库。方法是在目录中执行git init,执行之后在该项目目录中有个 .git 的子目录,这就是git仓库,所有相关的此项目的快照数据都将存放在这里
git clone:复制一个 git 仓库。方法:执行 git clone [url],[url] 为你想要复制的项目

6.每次提交都忽略.idea文件夹里面的东西怎么办

rimideiMac-51:P1805 admin$ ls
P1805		file		file2.idea	test.idea
README.md	file1.idea	test
rimideiMac-51:P1805 admin$ echo "*.idea" > .gitignore
rimideiMac-51:P1805 admin$ cat .gitignore
*.idea
rimideiMac-51:P1805 admin$ git add .
rimideiMac-51:P1805 admin$ git status
位于分支 master
您的分支与上游分支 'origin/master' 一致。

要提交的变更:
  (使用 "git reset HEAD <文件>..." 以取消暂存)

	新文件:   .gitignore
	新文件:   file
	新文件:   test

7、如果编辑一个文件之后并且加入了暂存区,但是你后悔了,想把文件恢复到没有修改之前的样子,怎么办

rimideiMac-51:P1805 admin$ ls
P1805		file		file2.idea	test.idea
README.md	file1.idea	test
rimideiMac-51:P1805 admin$ vim file
rimideiMac-51:P1805 admin$ git add file
rimideiMac-51:P1805 admin$ git status
位于分支 master
您的分支与上游分支 'origin/master' 一致。

要提交的变更:
  (使用 "git reset HEAD <文件>..." 以取消暂存)

	新文件:   file

未跟踪的文件:
  (使用 "git add <文件>..." 以包含要提交的内容)

	.gitignore/
	file1.idea
	file2.idea
	test
	test.idea

rimideiMac-51:P1805 admin$ git reset HEAD file

8、如何检出标签?

rimideiMac-51:P1805 admin$ git log
commit 945e277d33369be735cde3142454e5b6ddaf6857 (HEAD -> master)
Author: admin <admin@rimideiMac-51.local>
Date:   Mon Nov 19 20:06:09 2018 +0800

    V1.0

commit 2f4f59c3c7f760f0ad90a38639595a2c0c97a2a0 (origin/master, origin/HEAD)
Author: admin <admin@rimideiMac-51.local>
Date:   Fri Nov 16 14:57:15 2018 +0800

    第一次修改

commit f5dbbc76cc38486aff8d7dc982c47c01855459c8
Author: xgy <xgypython@163.com>
Date:   Fri Nov 16 14:45:01 2018 +0800

    Initial commit
rimideiMac-51:P1805 admin$ git tag v1.0.1
rimideiMac-51:P1805 admin$ git tag v1.0.2 2f4f59
rimideiMac-51:P1805 admin$ git tag
v1.0.1
v1.0.2
rimideiMac-51:P1805 admin$ git show v1.0.2
commit 2f4f59c3c7f760f0ad90a38639595a2c0c97a2a0 (tag: v1.0.2, origin/master, origin/HEAD)
Author: admin <admin@rimideiMac-51.local>
Date:   Fri Nov 16 14:57:15 2018 +0800

    第一次修改

diff --git a/P1805 b/P1805
new file mode 100644
index 0000000..b0c9c24
--- /dev/null
+++ b/P1805
@@ -0,0 +1 @@
+git教学

9、git fetch 和 git pull的区别

1、git fetch 相当于是从远程获取最新版本到本地,不会自动merge;这将更新git remote 中所有的远程仓库所包含分支的最新commit-id, 将其记录到.git/fetch_head文件中
2. git pull:相当于是从远程获取最新版本并merge到本地

10、如何添加远程仓库

rimideiMac-51:git教程 admin$ mkdir git-test
rimideiMac-51:git教程 admin$ cd git-test
rimideiMac-51:git-test admin$ echo '练习' > file
rimideiMac-51:git-test admin$ git init
已初始化空的 Git 仓库于 /Users/admin/Desktop/git教程/git-test/.git/
rimideiMac-51:git教程 admin$ git remote add git-test https://gitee.com/xgypython/P1805    (//git remote add git-test https://gitee.com/xgypython/P1805 即为添加远程仓库)
rimideiMac-51:git教程 admin$ git remote -v
git-test	https://gitee.com/xgypython/P1805 (fetch)
git-test	https://gitee.com/xgypython/P1805 (push)

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值