-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunixcommands.html
180 lines (173 loc) · 3.81 KB
/
unixcommands.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<html>
<head>
<title>Unix commands</title>
<style>
h1 {text-align: center; color: tomato; font-size:60px;}
h2 {text-align: left; color: black; font-size:40px;}
h2 {text-align: left; color: black; font-size:30px;}
h3 {text-align: center; color: black; font-size:18px;}
p {text-align: left; color: black; font-size:18px;}
img {display: block; margin-left: auto; margin-right: auto;}
footer {text-align: center; color: grey;}
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 100%;
}
td, th {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
tr:nth-child(even) {
background-color: #dddddd;
}
</style>
</head>
<h1>Cheat Sheet for Unix Commands</h1>
<h3>Create date: May 3 2024</h3>
<p>Go back to the main page <a href="index.html" target="_self">View</a></p>
<p>You will get some useful unix commands here.</p>
<table>
<tr>
<th>Command</th>
<th>Function</th>
</tr>
<tr>
<td>cd dir
<td>go to a directory
</tr>
<tr>
<td>cd ..
<td>go to previous directory
</tr>
<tr>
<td>cp [] dir/fname [] newdir
<td>copy a file to another directory
</tr>
<tr>
<td>ls []. Options: -a, -l
<td>list.
</tr>
<tr>
<td>pwd
<td>current directory
</tr>
<tr>
<td>rm fname; rm -r dir
<td>remove a file/directory
</tr>
<tr>
<td>vim fname
<td>create and edit a file
</tr>
<tr>
<td>mv fname1 fname2
<td>rename fname1 to fname2
</tr>
<tr>
<td>mkdir dir
<td>create a directory
</tr>
<tr>
<td>rmdir
<td>remove a directory
</tr>
<tr>
<td>mv fname dir
<td>move a file to a directory
</tr>
<tr>
<td>cp [] dir/fname [] newdir
<td>copy a file to another directory
</tr>
<tr>
<td>df -h
<td>check storage
</tr>
<tr>
<td>chmod [] fname
<td>change access permissions, further read <a href="https://en.wikipedia.org/wiki/Chmod" target="_self">View</a>
</tr>
<tr>
<td>source appname
<td>execute an application
</tr>
</table>
<p>When viewing or editing a file (e.g. using vi command), use following command.</p>
<table>
<tr>
<th>Command</th>
<th>Function</th>
</tr>
<tr>
<td>i
<td>insert, able to edit
</tr>
<tr>
<td>:wq
<td>save and quit
</tr>
<tr>
<td>q
<td>quit
</tr>
<tr>
<td>q!
<td>quit without save
</tr>
</table>
<p>Other useful commands.</p>
<table>
<tr>
<th>Command</th>
<th>Function</th>
</tr>
<tr>
<td>*
<td>all. e.g. "*.dat" means all files with ".dat" as names
</tr>
<tr>
<td>module avail modulename
<td>check available module
</tr>
<tr>
<td>which fname
<td>find where is file installed
</tr>
<tr>
<td>pip3 show modulename
<td>display the module version and other data
</tr>
<tr>
<td>modulename --version
<td>check the version of module
</tr>
<tr>
<td>matlab -nodisplay < fname
<td>run matlab code without opening application
</tr>
<tr>
<td>zip fname.zip fname1 fname2; zip dir.zip dir1 dir2
<td>zip files or directories
</tr>
<tr>
<td>unzip fname.zip
<td>unzip a zip file
</tr>
<tr>
<td>tar -zcvf fname.tgz fname1 fname2; tar -zcvf fname.tgz dir1 dir2
<td>zip files or directories
</tr>
<tr>
<td>tar -zxvf fname.tgz
<td>unzip a zip file
</tr>
</table>
<h2>SCP password prompt and file transfer</h2>
1. Password prompt: https://avsitter.github.io/mydoc_no_password_prompts_scp.html <br>
2. file transfer: <br>
1) Copy a file to the remote server: scp ~/Document/Localfile remoteuser@remotemachine:~/Desktop <br>
2) Download a file from the remote server: scp remoteuser@remotemachine:~/Destkop/remotefile ~/Desktop <br>
NOTE: use '-r' when processing directories; stay in local machine (not ssh server) when downloading or uploading <br>
</html>