display error

Alicelinux

New Member
Joined
Sep 23, 2018
Messages
23
Reaction score
0
Credits
0
in the console, i type cat /var/log/secure-20180516.gz, it display a lot of unreadable character on the screen, after that, the new command i type in all display wrongly, also the hostname appears human not readble character, any way to recover. thanks
 


OP
A

Alicelinux

New Member
Joined
Sep 23, 2018
Messages
23
Reaction score
0
Credits
0
if i type clear , it shows in the screen like
upload_2018-10-2_11-33-15.png
 

JasKinasis

Well-Known Member
Joined
Apr 25, 2017
Messages
1,615
Reaction score
2,315
Credits
12,249
The problem is occurring because you used cat to echo a binary file (gzipped text) to the terminal. Which causes cat to interpret bytes from the file as characters and display them. These byte sequences could appear as any character, including special control characters that will affect the terminals display. If any of these special control characters are printed in the terminal, they can cause all kinds of strange terminal behaviours to manifest.

So when you try to run any commands after cat-ing a binary file like that, the terminal sometimes appears to be malfunctioning, showing nonsensical characters etc.

The way to fix it is normally to reinitialise the terminal using something like:
Code:
. ~/.bashrc
And/or:
Code:
. ~/.profile
Or simply shut down the terminal and start a new one.
 
OP
A

Alicelinux

New Member
Joined
Sep 23, 2018
Messages
23
Reaction score
0
Credits
0
I'm in /var/log directory, so should i type: cd root, then . / bashrc or directly type bashrc?
 

JasKinasis

Well-Known Member
Joined
Apr 25, 2017
Messages
1,615
Reaction score
2,315
Credits
12,249
I'm in /var/log directory, so should i type: cd root, then . / bashrc or directly type bashrc?
No, because that's not what I typed in my post at all.
What I posted was:
Code:
. ~/.bashrc

There are two distinct words in that command, separated by a space.
The first word is . (aka the source command) then a space and then the final part ~/.bashrc is the path to the .bashrc in the current users home directory. The ~/ part is literally a shortcut for /home/yourusername/

So ~/.bashrc would expand to home/yourusername/.bashrc

The entire line is equivalent to:
Code:
source /home/yourusername/.bashrc

Which involves a little more typing. And I'm lazy, so I use shortcuts wherever possible!

And the paths used are absolute, so it doesn't matter where you are in the filesystem.
You could issue the commands in my previous post from anywhere. All it does is reloads the specified config file.

And it's exactly the same with the .profile file!

Does that make sense now?
 
Last edited:
OP
A

Alicelinux

New Member
Joined
Sep 23, 2018
Messages
23
Reaction score
0
Credits
0
I now use . ~/.bashrc, it executes, but error still the same, i use ctrl+D, now it is in "$" prompt , but error still the same, any suggestion
 

JasKinasis

Well-Known Member
Joined
Apr 25, 2017
Messages
1,615
Reaction score
2,315
Credits
12,249
If reloading .bashrc didn't help, did you try reloading .profile?

Failling that, you'll need to close the terminal and start a new one. Or log out and log in again?
Or if this is a remote computer, perhaps try rebooting it?!
 
$100 Digital Ocean Credit
Get a free VM to test out Linux!

Linux.org Hosting Donations
Consider making a donation

Members online

No members online now.

Latest posts

Top