Basic Unix command for SQL DBA's – Part1
MSSQL Basic Linux command, Basic Unix command, basic Unix command for SQL DBA, SQL Server on Linux, top 10 Linux command, Top 10 Unix command, Unix commandIn this article, we will learn basic Unix commands which SQL DBA's can use in their day to day database operations.
- ls : it shows files/directories in current working directory.
a)Directories are denoted with blue color
b)Files are with white color
![](https://dbalyfe.com/wp-content/uploads/2021/07/image-109.png)
2. ls -lrt : it shows detailed information of files and directories.
![](https://dbalyfe.com/wp-content/uploads/2021/07/image-110.png)
3. ls -lrt |grep ^d : this command is used to display only directories and not files.
![](https://dbalyfe.com/wp-content/uploads/2021/07/image-135.png)
4. ls -lart : it shows files/directories along with hidden files in present working directory. hidden files begin with period symbol(dot).
![](https://dbalyfe.com/wp-content/uploads/2021/07/image-111.png)
5. ls -R : It shows all the files and directories along with subdirectories and underneath files.
![](https://dbalyfe.com/wp-content/uploads/2021/07/image-112.png)
6. pwd : this command is used to find current working directory. in below example, we are in /home/dbalyfe directory.
![](https://dbalyfe.com/wp-content/uploads/2021/07/image-124.png)
7. cd : this command is used to navigate to specific directory.
in below example, we are in /home/dbalyfe directory and we would like to go to Test directory, so we will use cd to navigate to required directory.
![](https://dbalyfe.com/wp-content/uploads/2021/07/image-126.png)
cd .. — > to move one directory up
cd ~ — > to go to home directory
![](https://dbalyfe.com/wp-content/uploads/2021/07/image-127.png)
8. cat : this command is used to view file content. It can also be used to create files.
![](https://dbalyfe.com/wp-content/uploads/2021/07/image-113.png)
![](https://dbalyfe.com/wp-content/uploads/2021/07/image-114.png)
If we want to combine 2 files into 1 file, then it can be achieved via cat command as shown below.
![](https://dbalyfe.com/wp-content/uploads/2021/07/image-123.png)
9. touch : this command is used to create blank file.
![](https://dbalyfe.com/wp-content/uploads/2021/07/image-129.png)
10. rm : this command is used to remove file/s
![](https://dbalyfe.com/wp-content/uploads/2021/07/image-117.png)
11. mv : this command is used to move files from one directory to another directory. it is also used to rename files.
in below example, Test2.txt is renamed to Test4.txt within same present working directory.
![](https://dbalyfe.com/wp-content/uploads/2021/07/image-120.png)
In below example, Test1.txt file is being moved from its current directory /home/dbalyfe to /home/dbalyfe/Test directory.
![](https://dbalyfe.com/wp-content/uploads/2021/07/image-118.png)
12. mkdir : this command is used to create directory.
![](https://dbalyfe.com/wp-content/uploads/2021/07/image-121.png)
13. cp : this command is used to copy files from one directory to another directory.
In below example, Test4.txt file is being copied from its current directory /home/dbalyfe to /home/dbalyfe/Test directory.
![](https://dbalyfe.com/wp-content/uploads/2021/07/image-131.png)
14. cp -p : this command is used to copy the file keeping the source file timestamp.
In above example, if you notice copied file has got its current timestamp and not as source file timestamp. we can achieve this using cp -p
![](https://dbalyfe.com/wp-content/uploads/2021/07/image-130.png)
15. tail : this command shows last 10 files(default 10) from bottom.
![](https://dbalyfe.com/wp-content/uploads/2021/07/image-133.png)
16. chmod : this command is used to give required permission to file
![](https://dbalyfe.com/wp-content/uploads/2021/07/image-136.png)
17. uname : this command is used to know Unix flavor
![](https://dbalyfe.com/wp-content/uploads/2021/07/image-139.png)
18. hostname : this command is used to get the server host name
![](https://dbalyfe.com/wp-content/uploads/2021/07/image-140.png)
19. find : this command is used to find files from required directories. in below example we are searching Test1.txt file in current directory.
![](https://dbalyfe.com/wp-content/uploads/2021/07/image-143.png)
In below example, we have to search for file Test5.txt and it is available under /home/dbalyfe/Test, so we are in /home/dbalyfe directory and try to search for that file. find command will search for file in all the directories as well as subdirectories and display the result.
![](https://dbalyfe.com/wp-content/uploads/2021/07/image-144.png)
20. history : this command is used to check previously ran history of commands
![](https://dbalyfe.com/wp-content/uploads/2021/07/image-142.png)
21. df : this command is used to display file system usage of Unix operating system.
![](https://dbalyfe.com/wp-content/uploads/2021/07/image-145.png)
How useful was this post?
Click on a star to rate it!
Average rating 0 / 5. Vote count: 0
No votes so far! Be the first to rate this post.